[issue41872] get_type_hints fails to resolve forward references in nested function

Guido van Rossum report at bugs.python.org
Sun Sep 27 15:59:08 EDT 2020


Guido van Rossum <guido at python.org> added the comment:

This cannot be helped (unless we were to add an ugly sys._getframe() call to get_type_hints(), which I don't want to do). The solution is to pass `localns=locals()`, e.g.

get_type_hints(foo, None, locals())

or

get_type_hints(foo, localns=locals())

----------
keywords: +3.6regression
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41872>
_______________________________________


More information about the Python-bugs-list mailing list