Isn't that just typing.get_type_hints()?
On Mon, Jan 11, 2021 at 5:11 PM Greg Ewing email@example.com 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 -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://firstname.lastname@example.org/message/DXQJ2V32... Code of Conduct: http://python.org/psf/codeofconduct/