Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-110686: Test pattern matching with runtime_checkable protocols #290

Merged
merged 3 commits into from
Oct 31, 2023

Conversation

sobolevn
Copy link
Member

@AlexWaygood
Copy link
Member

You'll need to make this change if you want the tests to pass on Python 3.12:

--- a/src/test_typing_extensions.py
+++ b/src/test_typing_extensions.py
@@ -5085,12 +5085,12 @@ class AllTests(BaseTestCase):
             exclude |= {'final', 'Any', 'NewType'}
         if sys.version_info < (3, 12):
             exclude |= {
-                'Protocol', 'SupportsAbs', 'SupportsBytes',
+                'SupportsAbs', 'SupportsBytes',
                 'SupportsComplex', 'SupportsFloat', 'SupportsIndex', 'SupportsInt',
                 'SupportsRound', 'Unpack',
             }
         if sys.version_info < (3, 13):
-            exclude |= {'NamedTuple', 'TypedDict', 'is_typeddict'}
+            exclude |= {'NamedTuple', 'Protocol', 'TypedDict', 'is_typeddict'}
         for item in typing_extensions.__all__:
             if item not in exclude and hasattr(typing, item):
                 self.assertIs(
diff --git a/src/typing_extensions.py b/src/typing_extensions.py
index cb3410e..b900335 100644
--- a/src/typing_extensions.py
+++ b/src/typing_extensions.py
@@ -506,7 +506,7 @@ def _caller(depth=2):

 # The performance of runtime-checkable protocols is significantly improved on Python 3.12,
 # so we backport the 3.12 version of Protocol to Python <=3.11
-if sys.version_info >= (3, 12):
+if sys.version_info >= (3, 13):
     Protocol = typing.Protocol
 else:
     def _allow_reckless_class_checks(depth=3):

I think a CHANGELOG entry would also be good :)

@JelleZijlstra JelleZijlstra merged commit fc9acbd into python:main Oct 31, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants