On 4/20/21 10:03 AM, Mark Shannon wrote:
Then came PEP 563 and said that if you wanted to access the
annotations of an object, you needed to call typing.get_type_hints()
to get annotations in a meaningful form.
This smells a bit like enforced static typing to me.
I'm working to address this. We're adding a new function to the
standard library called inspect.get_annotations(). It's a lot less
opinionated than typing.get_type_hints()--it simply returns the
un-stringized annotations. It also papers over some other awkward
annotations behaviors, such as classes inheriting annotations from base
classes. I propose that it be the official new Best Practice for
accessing annotations (as opposed to type hints, you should still use
typing.get_type_hints() for that).
https://bugs.python.org/issue43817
This will get checked in in time for Python 3.10b1.
Cheers,
//arry/
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/7TUTEDQ6MDKDV5VQCRLFUYI2XP3DIPDS/
Code of Conduct: http://python.org/psf/codeofconduct/