mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin (GH-23942)
This commit is contained in:
parent
a6d63a20df
commit
efb1f0918f
3 changed files with 15 additions and 1 deletions
|
@ -3021,6 +3021,7 @@ class GetUtilitiesTestCase(TestCase):
|
|||
self.assertIs(get_origin(Callable), collections.abc.Callable)
|
||||
self.assertIs(get_origin(list[int]), list)
|
||||
self.assertIs(get_origin(list), None)
|
||||
self.assertIs(get_origin(list | str), types.Union)
|
||||
|
||||
def test_get_args(self):
|
||||
T = TypeVar('T')
|
||||
|
@ -3053,6 +3054,11 @@ class GetUtilitiesTestCase(TestCase):
|
|||
self.assertEqual(get_args(collections.abc.Callable[[], str]), ([], str))
|
||||
self.assertEqual(get_args(collections.abc.Callable[[int], str]),
|
||||
get_args(Callable[[int], str]))
|
||||
P = ParamSpec('P')
|
||||
self.assertEqual(get_args(Callable[P, int]), (P, int))
|
||||
self.assertEqual(get_args(Callable[Concatenate[int, P], int]),
|
||||
(Concatenate[int, P], int))
|
||||
self.assertEqual(get_args(list | str), (list, str))
|
||||
|
||||
|
||||
class CollectionsAbcTests(BaseTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue