Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
order of attributes is 'backwards' in case of multiple inheritance #298
consider following code. I also added a dummy method
from attr import attributes, attr @attributes class A(object): a = attr() def m(self): print("A.m") @attributes class B(object): b = attr() def m(self): print("B.m") @attributes class C(A, B): c = attr() def m(self): super(C, self).m() @classmethod def supers(cls): return cls.__bases__ c = C(1, 2, 3) print(c) c.m() print("supers=%s" % str(c.supers()))
running it results in
so the first argument is (IMHO) incorrectly assigned to attribute b not a, and then 2nd one to a...
Before recent 3040bda quick and dirty (and possibly incomplete) fix was to remove
referenced this issue
Nov 27, 2017
Sorry I didn't get around this any earlier, but I wanted to have a weekend so I can wrap my head around it.
You’re right, we’ve been traversing the MRO wrongly until recently. I have a fix similar to yours, I’m just not 100% sure how to proceed. It seems that this bug is rather old and fixing it is technically breaking backward compatibility.
I’m tending to rip of the bandaid tho, since it’s clearly behaving wrongly.