[issue43817] Add inspect.get_annotations()

Eric V. Smith report at bugs.python.org
Thu Apr 22 07:33:38 EDT 2021


Eric V. Smith <eric at trueblade.com> added the comment:

> To be honest, I've never been really sure if the idea of PEP 563 stringized annotations are supposed to be a hidden implementation detail, or a first-class concept that the user (and the standard library) is expected to deal with.

This is an excellent question. My assumption with dataclasses has been that it's something the user is expected to deal with. It's a user-visible change, that all users of __annotations__ are going to have to deal with. I understood PEP 573 as saying: if you don't want to see a stringized annotation, call typing.get_type_hints() yourself. My assumption is that neither @dataclass nor anybody else is going to do that for you.

However, not everyone agreed. See for example issue 39442.

I do think that wherever we end up with __annotations__ in 3.11, we should be explicit about answering your question.

----------

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


More information about the Python-bugs-list mailing list