New submission from Lincoln Quirk <linc...@wave.com>:
Consider this code: ``` from __future__ import annotations import typing class A: f: 'Undef' hints = typing.get_type_hints(A) ``` Since Undef is not defined, I should get an exception when calling get_type_hints, something like "NameError: name 'Undef' is not defined". But instead, get_type_hints returns {'f': ForwardRef('Undef')}. If I remove the `from __future__ import annotations` line, get_type_hints correctly raises this exception. I think the behavior should be to raise an exception in both cases. ---------- messages: 334396 nosy: Lincoln Quirk priority: normal severity: normal status: open title: get_type_hints exposes an instance of ForwardRef (internal class) in its result, with `from __future__ import annotations` enabled type: behavior versions: Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35834> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com