Closed
Description
This code now generates an error about class AB:
import attr
@attr.s
class A:
x = attr.ib(type=int)
@attr.s
class B:
y = attr.ib(type=int)
# Definition of "__attrs_attrs__" in base class "A" is incompatible with definition in base class "B"
class AB(A, B):
pass
The code is arguably questionable, and the error goes away if we decorate AB with @attr.s
, but that's not clear from the error message. It would be better to add a note, such as something like this:
... :note: Should class "AB" use the @attr.s decorator?
This started happening after #11794, and it might be considered a minor regression because of the confusing message.
(Behind the scenes, a __attrs_attrs__
attribute gets generated with a class-specific named tuple as the type. These named tuples aren't compatible with each other.)
cc @Tinche