◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
5 changes: 5 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
@@ -3071,6 +3071,11 @@ class C(Generic[T]): pass
self.assertEqual(get_args(Callable), ())
self.assertEqual(get_args(list[int]), (int,))
self.assertEqual(get_args(list), ())


class CollectionsAbcTests(BaseTestCase):
Expand Down
4 changes: 1 addition & 3 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1507,13 +1507,11 @@ def get_args(tp):
"""
if isinstance(tp, _AnnotatedAlias):
return (tp.__origin__,) + tp.__metadata__
if isinstance(tp, _GenericAlias):
res = tp.__args__
if tp.__origin__ is collections.abc.Callable and res[0] is not Ellipsis:
res = (list(res[:-1]), res[-1])
return res
if isinstance(tp, GenericAlias):
return tp.__args__
return ()


Expand Down
Toggle all file notes Toggle all file annotations