You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importattrclassBase:
x=0@attr.s(auto_attribs=True)classC(Base):
x: int
This raises an:
Traceback (most recent call last):
File "t.py", line 9, in <module>
class C(Base):
File "/Users/hynek/Projects/attrs/src/attr/_make.py", line 858, in wrap
return builder.build_class()
File "/Users/hynek/Projects/attrs/src/attr/_make.py", line 496, in build_class
return self._patch_original_class()
File "/Users/hynek/Projects/attrs/src/attr/_make.py", line 514, in _patch_original_class
delattr(cls, name)
AttributeError: x
(interestingly getattr(cls, name) works but delattr does not)
This is actually quite common if you implement an ABC. The current code is:
if (
namenotinsuper_namesandgetattr(cls, name, None) isnotNone
):
delattr(cls, name)
Maybe we should change the check to isinstance(getattr(cls, name, None), _CountingAttr)?
The text was updated successfully, but these errors were encountered:
Consider the following:
This raises an:
(interestingly
getattr(cls, name)
works butdelattr
does not)This is actually quite common if you implement an ABC. The current code is:
Maybe we should change the check to
isinstance(getattr(cls, name, None), _CountingAttr)
?The text was updated successfully, but these errors were encountered: