-
-
Notifications
You must be signed in to change notification settings - Fork 425
Closed
Labels
Description
attrs-decorated classes can produce unexpected behaviour when they exist in an inheritance tree with non-attrs-decorated classes that define their own __init__ methods, because those __init__ methods aren't called. This dumb test exercises this:
def test_init_with_multiple_inheritance():
import attr
@attr.s
class A(object):
a = attr.ib(default=42)
class B(object):
def __init__(self):
super(B, self).__init__()
self.b = 3
class C(A, B):
pass
c = C()
assert c.a == 42
assert c.b == 3The second assertion currently fails with an AttributeError.
In ordinary Python code this would be addressed with a super call in A.__init__, but I'm not sure if adding a super to the __init__ returned from _attrs_to_script would achieve the same result without breaking a bunch of other cases.
(I apologise for not digging further & submitting a patch; the code in _make.py is a little too terrifying to get stuck into a Monday morning!)
Reactions are currently unavailable