[issue43901] Add an empty annotations dict to all unannotated classes and modules

Larry Hastings report at bugs.python.org
Sat Apr 24 18:26:42 EDT 2021


Larry Hastings <larry at hastings.org> added the comment:

I'm please you folks are as supportive as you are of what I'm doing here, given that you seem a little unsure of the details.  I concede that there's a lot going on and it can be hard to keep it all in your head.

The point of this issue / PR is to improve the best practices for 3.10 without breaking the best practices for 3.9 and before.

Best practice in 3.10 is to use inspect.get_annotations(), and failing that, three-argument getattr(), for all annotated objects.  This issue / PR permits that to happen.

Best practices for 3.9 differed between different objects.  For classes, you had no choice but to look in the class dict because of the inheritance problem.  (Either that, or, the elaborate scheme 'attrs' used.)  That code will emphatically _still work_ in 3.10.  We are not breaking backwards compatibility.

So, the best practices in 3.9 and before will still work in 3.10.  But the best practices for 3.10+ are improved because of the work we're doing here and in other places.

My intent was to document the best practices for 3.10+.  If folks think it would be helpful, this same section in the 3.10 docs can also describe best practices for 3.9 and before.

----------

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


More information about the Python-bugs-list mailing list