New submission from Chris Withers <ch...@withers.org>:
Reproducer: def test_forward_type_references(self): def foo(a: 'Foo') -> 'Bar': pass class Foo: pass class Bar: pass get_type_hints(foo) The above gives the following exception, rather than resolving the type: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:1001: in get_type_hints value = _eval_type(value, globalns, localns) /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:260: in _eval_type return t._evaluate(globalns, localns) /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:464: in _evaluate eval(self.__forward_code__, globalns, localns), _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ??? E NameError: name 'Foo' is not defined ---------- components: Library (Lib) messages: 377569 nosy: cjw296 priority: normal severity: normal status: open title: get_type_hints fails to resolve forward references in nested function type: behavior versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41872> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com