[issue43817] Add inspect.get_annotations()

Eric V. Smith report at bugs.python.org
Wed Apr 21 06:00:42 EDT 2021


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

> If o.__annotations__ is None, should this function set the empty dict on the object?  That seems slightly too opinionated to me.  On the other hand, the user would probably expect that they could change the dict they got back.

Are you saying the user would expect to be able to change __annotations__ my modifying the dict they get back?

Is it ever the case that the user can modify __annotations__ through the dict that's returned? That is: does __annotations__ itself ever get returned?

I think you'd either want __annotations__ returned all the time, or never returned. Otherwise some cases could modify __annotations__, and some couldn't.

If __annotations__ is never returned, then I wouldn't set __annotations__ in this case.

----------

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


More information about the Python-bugs-list mailing list