]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063)
authorNikita Sobolev <mail@sobolevn.me>
Sat, 19 Feb 2022 01:54:01 +0000 (04:54 +0300)
committerGitHub <noreply@github.com>
Sat, 19 Feb 2022 01:54:01 +0000 (17:54 -0800)
Lib/test/test_typing.py

index d24a3571343617d6456565eed83497eadda194dc..3dc9497c3a02e86088aed7624ec284860056068f 100644 (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"]