[issue39442] from __future__ import annotations makes dataclasses.Field.type a string, not type

Dave Tapley report at bugs.python.org
Thu Sep 9 23:24:42 EDT 2021


Dave Tapley <dave at tapley.com> added the comment:

I don't know if it helps, but I just ran in to this when I followed the advice at (1) because I wanted to type hint a method with the type of the enclosing class.

This broke a package I'm working on in parallel (2) because it uses dataclasses.fields internally.

I'm not sure what the advice would be here, should my package detect if the caller has `from __future__ import annotations` and do something?



(1) https://stackoverflow.com/questions/33533148/how-do-i-type-hint-a-method-with-the-type-of-the-enclosing-class/33533514#33533514
(2) https://pypi.org/project/dataclasses-configobj/

----------
nosy: +davetapley

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39442>
_______________________________________


More information about the Python-bugs-list mailing list