[Python-checkins] bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063)

JelleZijlstra webhook-mailer at python.org
Fri Feb 18 20:54:05 EST 2022


https://github.com/python/cpython/commit/25c0b9d243b64ccd2eeab483089eaf7e4b4d5834
commit: 25c0b9d243b64ccd2eeab483089eaf7e4b4d5834
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-02-18T17:54:01-08:00
summary:

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

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index d24a357134361..3dc9497c3a02e 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3549,6 +3549,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"]



More information about the Python-checkins mailing list