Skip to content

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

Merged
JelleZijlstra merged 3 commits intopython:mainfrom
sobolevn:add-match-args
Oct 31, 2023
Merged

gh-110686: Test pattern matching with runtime_checkable protocols#290
JelleZijlstra merged 3 commits intopython:mainfrom
sobolevn:add-match-args

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
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