Skip to content

Commit 058a38e

Browse files
committed
pythonGH-103629: Prettify Unpack's repr
1 parent 2f26dbd commit 058a38e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Lib/test/test_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def test_usage_with_kwargs(self):
884884
Movie = TypedDict('Movie', {'name': str, 'year': int})
885885
def foo(**kwargs: Unpack[Movie]): ...
886886
self.assertEqual(repr(foo.__annotations__['kwargs']),
887-
f"typing.Unpack[<class '{__name__}.Movie'>]")
887+
f"typing.Unpack[{__name__}.Movie]")
888888

889889
class TypeVarTupleTests(BaseTestCase):
890890

Lib/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ class _UnpackGenericAlias(_GenericAlias, _root=True):
17781778
def __repr__(self):
17791779
# `Unpack` only takes one argument, so __args__ should contain only
17801780
# a single item.
1781-
return f'typing.Unpack[{repr(self.__args__[0])}]'
1781+
return f'typing.Unpack[{_type_repr(self.__args__[0])}]'
17821782

17831783
def __getitem__(self, args):
17841784
if self.__typing_is_unpacked_typevartuple__:

0 commit comments

Comments
 (0)