summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-11-21 17:43:42 (GMT)
committerGitHub <noreply@github.com>2019-11-21 17:43:42 (GMT)
commit9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3 (patch)
tree33650f1c330f62708b4cb6fa8f118b1d2dfd71e9 /Lib/test/test_typing.py
parent767b42633bb7ac39dd6743d8dd7f5b5cc122acea (diff)
downloadcpython-9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3.zip
cpython-9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3.tar.gz
cpython-9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3.tar.bz2
bpo-37838: get_type_hints for wrapped functions with forward reference (GH-17126)
https://bugs.python.org/issue37838 (cherry picked from commit 0aca3a3a1e68b4ca2d334ab5255dfc267719096e) Co-authored-by: benedwards14 <53377856+benedwards14@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 104b7c0..ded5a8b 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -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):