Isn't that just typing.get_type_hints()? On Mon, Jan 11, 2021 at 5:11 PM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
On 12/01/21 6:22 am, Larry Hastings wrote:
* The language will set __annotations__ to a dict if the object has
annotations, or None if it has no annotations.
That sounds inconvenient -- it means that any code referencing __annotations__ has to guard against the possibility of it being None.
If we're changing things, I'm wondering if the best thing would be to introduce an annotations() function as the new best practice for getting an object's annotations. It would know how to handle all the type-specific pecularities, and could take care of things such as manufacturing an empty dict if the object doesn't have any annotations.
-- Greg _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@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/DXQJ2V32... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>