Larry Hastings <la...@hastings.org> added the comment:

By the way, here's a tidbit I never got around to posting in c.l.p-d.

I noted in the conversation in January that attrs is an outlier here: it 
*doesn't* look in the class dict for __annotations__.  Instead, it has some 
complicated code where it asks the class for its annotations, then iterates 
over the __mro__ and asks every base class for *its* annotations.  If the class 
and a base class have the same class dict (using the "is" operator iirc) then 
attrs says "oh, that class doesn't have its own annotations, it's inheriting 
them" and reacts appropriately.

I emailed Hynek to ask him why he did it that way.  It turns out, he did that 
because at the time he didn't know you could peek in the class dict for 
__annotations__.  He literally had a todo item saying "change to looking in the 
class dict".

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43901>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to