Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7def253

Browse filesBrowse files
authored
Fix isinstance(Unpack[Ts], TypeVar) to be False in 3.11 (#539)
1 parent 3f47bf9 commit 7def253
Copy full SHA for 7def253

File tree

3 files changed

+12
-1
lines changed
Filter options

3 files changed

+12
-1
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ aliases that have a `Concatenate` special form as their argument.
4242
to reflect Python 3.13+ behavior: A value assigned to `__total__` in the class body of a
4343
`TypedDict` will be overwritten by the `total` argument of the `TypedDict` constructor.
4444
Patch by [Daraan](https://github.com/Daraan), backporting a CPython PR by Jelle Zijlstra.
45+
- Fix for Python 3.11 that now `isinstance(typing_extensions.Unpack[...], TypeVar)`
46+
evaluates to `False`, however still `True` for <3.11.
47+
Patch by [Daraan](https://github.com/Daraan)
4548

4649
# Release 4.12.2 (June 7, 2024)
4750

‎src/test_typing_extensions.py

Copy file name to clipboardExpand all lines: src/test_typing_extensions.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6172,6 +6172,12 @@ def test_equivalent_nested_variadics(self):
61726172
self.assertEqual(nested_tuple_bare, TupleAliasTsT[Unpack[Tuple[str, int]], object])
61736173
self.assertEqual(nested_tuple_bare, TupleAliasTsT[Unpack[Tuple[str]], Unpack[Tuple[int]], object])
61746174

6175+
@skipUnless(TYPING_3_11_0, "Needed for backport")
6176+
def test_type_var_inheritance(self):
6177+
Ts = TypeVarTuple("Ts")
6178+
self.assertFalse(isinstance(Unpack[Ts], TypeVar))
6179+
self.assertFalse(isinstance(Unpack[Ts], typing.TypeVar))
6180+
61756181

61766182
class TypeVarTupleTests(BaseTestCase):
61776183

‎src/typing_extensions.py

Copy file name to clipboardExpand all lines: src/typing_extensions.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2657,7 +2657,9 @@ def __init__(self, getitem):
26572657
self.__doc__ = _UNPACK_DOC
26582658

26592659
class _UnpackAlias(typing._GenericAlias, _root=True):
2660-
__class__ = typing.TypeVar
2660+
if sys.version_info < (3, 11):
2661+
# needed for compatibility with Generic[Unpack[Ts]]
2662+
__class__ = typing.TypeVar
26612663

26622664
@property
26632665
def __typing_unpacked_tuple_args__(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.