bpo-46603: improve coverage of typing._strip_annotations (GH-31063)

This commit is contained in:
Nikita Sobolev 2022-02-19 04:54:01 +03:00 committed by GitHub
parent 395029b0bd
commit 25c0b9d243
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3549,6 +3549,15 @@ class GetTypeHintTests(BaseTestCase):
{"x": typing.Annotated[int | float, "const"]}
)
def test_get_type_hints_annotated_in_union(self): # bpo-46603
def with_union(x: int | list[Annotated[str, 'meta']]): ...
self.assertEqual(get_type_hints(with_union), {'x': int | list[str]})
self.assertEqual(
get_type_hints(with_union, include_extras=True),
{'x': int | list[Annotated[str, 'meta']]},
)
def test_get_type_hints_annotated_refs(self):
Const = Annotated[T, "Const"]