From df47bfe5a39bfc8df8133d9980aa155b4a4c2f1f Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 19 Feb 2022 04:54:01 +0300 Subject: [PATCH] bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063) (cherry picked from commit 25c0b9d243b64ccd2eeab483089eaf7e4b4d5834) Co-authored-by: Nikita Sobolev --- Lib/test/test_typing.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index c4c06008d91fa0..8ced27824205df 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3305,6 +3305,15 @@ def barfoo4(x: BA3): ... {"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"]