summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2022-02-19 01:54:01 (GMT)
committerGitHub <noreply@github.com>2022-02-19 01:54:01 (GMT)
commit25c0b9d243b64ccd2eeab483089eaf7e4b4d5834 (patch)
treec1fb753422743117ee293b5c881c86b0071080d6 /Lib
parent395029b0bd343648b4da8044c7509672ea768775 (diff)
downloadcpython-25c0b9d243b64ccd2eeab483089eaf7e4b4d5834.zip
cpython-25c0b9d243b64ccd2eeab483089eaf7e4b4d5834.tar.gz
cpython-25c0b9d243b64ccd2eeab483089eaf7e4b4d5834.tar.bz2
bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_typing.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index d24a357..3dc9497 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -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"]