This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cjw296
Recipients cjw296
Date 2020-09-27.13:58:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1601215084.02.0.220244006466.issue41872@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2020-09-27 13:58:04cjw296setrecipients: + cjw296
2020-09-27 13:58:04cjw296setmessageid: <1601215084.02.0.220244006466.issue41872@roundup.psfhosted.org>
2020-09-27 13:58:03cjw296linkissue41872 messages
2020-09-27 13:58:03cjw296create