bpo-34776: Fix dataclasses to support future "annotations" mode by 1st1 · Pull Request #9518 · python/cpython (original) (raw)

Strictly speaking, this problem is not directly related to __future__ annotations.
It's about postponed evaluation of type annotations in general, including forward references in pre-PEP-563 annotations.
Consider rewording along the lines of "Fix dataclasses to support forward references in type annotations".

Traceback (most recent call last):
  File ".\zzz.py", line 11, in <module>
    print(get_type_hints(C2.__init__))
  File "C:\Python37\lib\typing.py", line 1001, in get_type_hints
    value = _eval_type(value, globalns, localns)
  File "C:\Python37\lib\typing.py", line 260, in _eval_type
    return t._evaluate(globalns, localns)
  File "C:\Python37\lib\typing.py", line 464, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'T' is not defined
{'x': <class '__main__.T'>, 'return': <class 'NoneType'>}