◐ Shell
clean mode source ↗

Message 334396 - Python tracker

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.