diff options
author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2021-04-12 17:23:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 17:23:12 (GMT) |
commit | 852150ddfe68bc2696fc880175aeb855a0c16ae6 (patch) | |
tree | d4cd9bfcff32cb08f7bcdcf51d46bb82b45de397 /Lib/test/test_typing.py | |
parent | 37a5e220234dd4afb8f97b810393e3d58db674a1 (diff) | |
download | cpython-852150ddfe68bc2696fc880175aeb855a0c16ae6.zip cpython-852150ddfe68bc2696fc880175aeb855a0c16ae6.tar.gz cpython-852150ddfe68bc2696fc880175aeb855a0c16ae6.tar.bz2 |
bpo-42904: Fix get_type_hints for class local namespaces (GH-24201)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 82c517a..062163c 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2874,7 +2874,7 @@ class GetTypeHintTests(BaseTestCase): {'x': int, 'y': int}) self.assertEqual(gth(mod_generics_cache.B), {'my_inner_a1': mod_generics_cache.B.A, - 'my_inner_a2': mod_generics_cache.A, + 'my_inner_a2': mod_generics_cache.B.A, 'my_outer_a': mod_generics_cache.A}) def test_respect_no_type_check(self): @@ -3010,6 +3010,13 @@ class GetTypeHintTests(BaseTestCase): {'other': MySet[T], 'return': MySet[T]} ) + def test_get_type_hints_classes(self): + class Foo: + y = str + x: y + # This previously raised an error under PEP 563. + self.assertEqual(get_type_hints(Foo), {'x': str}) + class GetUtilitiesTestCase(TestCase): def test_get_origin(self): |