diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-11-21 17:43:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-21 17:43:42 (GMT) |
commit | 9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3 (patch) | |
tree | 33650f1c330f62708b4cb6fa8f118b1d2dfd71e9 /Lib/typing.py | |
parent | 767b42633bb7ac39dd6743d8dd7f5b5cc122acea (diff) | |
download | cpython-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/typing.py')
-rw-r--r-- | Lib/typing.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index bd30da9..69f6d98 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1234,7 +1234,11 @@ def get_type_hints(obj, globalns=None, localns=None): if isinstance(obj, types.ModuleType): globalns = obj.__dict__ else: - globalns = getattr(obj, '__globals__', {}) + nsobj = obj + # Find globalns for the unwrapped object. + while hasattr(nsobj, '__wrapped__'): + nsobj = nsobj.__wrapped__ + globalns = getattr(nsobj, '__globals__', {}) if localns is None: localns = globalns elif localns is None: |