diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2021-09-25 08:56:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-25 08:56:22 (GMT) |
commit | 784905dbeff68cf788bbeefe0a675af1af04affc (patch) | |
tree | ea65406abec0964e637a33da355e6edc33a9e94a /Lib/test/test_typing.py | |
parent | 4c0fc65cd8a6d4c18330505576ccd4b46abeec1c (diff) | |
download | cpython-784905dbeff68cf788bbeefe0a675af1af04affc.zip cpython-784905dbeff68cf788bbeefe0a675af1af04affc.tar.gz cpython-784905dbeff68cf788bbeefe0a675af1af04affc.tar.bz2 |
bpo-45166: fixes `get_type_hints` failure on `Final` (GH-28279)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index fa49b90..d1887f7 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2975,7 +2975,7 @@ else: # Definitions needed for features introduced in Python 3.6 -from test import ann_module, ann_module2, ann_module3 +from test import ann_module, ann_module2, ann_module3, ann_module5, ann_module6 from typing import AsyncContextManager class A: @@ -3339,6 +3339,22 @@ class GetUtilitiesTestCase(TestCase): (Concatenate[int, P], int)) self.assertEqual(get_args(list | str), (list, str)) + def test_forward_ref_and_final(self): + # https://bugs.python.org/issue45166 + hints = get_type_hints(ann_module5) + self.assertEqual(hints, {'name': Final[str]}) + + hints = get_type_hints(ann_module5.MyClass) + self.assertEqual(hints, {'value': Final}) + + def test_top_level_class_var(self): + # https://bugs.python.org/issue45166 + with self.assertRaisesRegex( + TypeError, + r'typing.ClassVar\[int\] is not valid as type argument', + ): + get_type_hints(ann_module6) + class CollectionsAbcTests(BaseTestCase): |