bpo-37838: get_type_hints for wrapped functions with forward reference (GH-17126)

https://bugs.python.org/issue37838
This commit is contained in:
benedwards14 2019-11-21 17:24:58 +00:00 committed by Ivan Levkivskyi
parent 82f897bf8f
commit 0aca3a3a1e
4 changed files with 28 additions and 1 deletions

View file

@ -2778,6 +2778,16 @@ except StopIteration as e:
gth = get_type_hints
class ForRefExample:
@ann_module.dec
def func(self: 'ForRefExample'):
pass
@ann_module.dec
@ann_module.dec
def nested(self: 'ForRefExample'):
pass
class GetTypeHintTests(BaseTestCase):
def test_get_type_hints_from_various_objects(self):
@ -2876,6 +2886,11 @@ class GetTypeHintTests(BaseTestCase):
'x': ClassVar[Optional[B]]})
self.assertEqual(gth(G), {'lst': ClassVar[List[T]]})
def test_get_type_hints_wrapped_decoratored_func(self):
expects = {'self': ForRefExample}
self.assertEqual(gth(ForRefExample.func), expects)
self.assertEqual(gth(ForRefExample.nested), expects)
class GetUtilitiesTestCase(TestCase):
def test_get_origin(self):