Message387328
Hmm I noticed this occurs in Python 3.9 but not 3.10. If you insert ``from __future__ import annotations`` at the start of your code, it stops erroring.
Anyways, I don't think this is dataclass specific, the following code using a plain class also errors:
```
from typing import get_type_hints
class T:
str: str = 'a'
get_type_hints(T) # Error.
```
Inspecting __annotations__ tells us why:
>>> T.__annotations__
{'str': 'a'}
You can see that the annotations are wrong. Meanwhile with from __future__ import annotations:
>>> T.__annotations__
{'str': 'str'}
Seeing that SETUP_ANNOTATIONS in ceval.c didn't change, I suspect it's compiler related. |
|
Date |
User |
Action |
Args |
2021-02-19 15:00:25 | kj | set | recipients:
+ kj, gvanrossum, eric.smith, xirdneh |
2021-02-19 15:00:25 | kj | set | messageid: <1613746825.07.0.301963570271.issue43257@roundup.psfhosted.org> |
2021-02-19 15:00:25 | kj | link | issue43257 messages |
2021-02-19 15:00:24 | kj | create | |
|