Passing these=d
to attr.s
skips attributes defined in class body
#621
Labels
these=d
to attr.s
skips attributes defined in class body
#621
This fails even if passing
auto_attribs=True
, albeit in a slightly different way.The obvious workaround is to only put attributes in
these
, but that is harder for code analysis tools to understand (it lacks type annotations, even if the tools areattrs
aware).The second workaround would be to put the attributes from
these
into the class body, but that doesn't work if the attribute is inherited or describe a data descriptor (likegetter/setter
s).The final workaround is to duplicate the definition into both
these
and the class body, but that creates an opportunity for the two to get out of sync.Anyway, ideally, attrs would add anything from the class body which is an instance of
_CountingAttr
, (and anything from the annotations dict ifauto_attribs
is set). If that is not practical, then a warning or exception should be raised rather than having weird runtime behavior.The text was updated successfully, but these errors were encountered: