We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Following code:
import attrs def decorated(method): def wrapped(self, *args, **kwargs): return method(self, *args, **kwargs) return wrapped @attrs.define() class A: def f(self): pass @attrs.define() class B(A): @decorated def f(self): super().f() B().f()
raises following error
TypeError: super(type, obj): obj must be an instance or subtype of type
If I use super(B, self), everything works just fine.
super(B, self)
The text was updated successfully, but these errors were encountered:
This problem is related to cell rewriting for slotted classes. Put simply we have to cheat a bit to make them work by rewriting method contents.
You get the same behavior with dataclasses:
@dataclasses.dataclass(slots=True) @attrs.define class C: @decorated def f(self): super().f()
Short fixes:
@attrs.define(slots=False)
Long-term fixes:
I'm a bit dubious if it's actually possible to fix tho. :-/ Maybe, if functools.wraps is used and we follow the __wrapped__ attributes?
functools.wraps
__wrapped__
Sorry, something went wrong.
Thanks for the quick response! I'll use super(B, self) for now.
@component
fix: call super properly in attrs classes
761dde0
Fixes #3 See python-attrs/attrs#1038 for more details
No branches or pull requests
Following code:
raises following error
If I use
super(B, self)
, everything works just fine.The text was updated successfully, but these errors were encountered: