python-attrs / python-attrs/attrs
TypeError when calling super() in decorated method
Open
Nobody has claimed this yet.
Bug
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied Python reproduction first and confirm the TypeError occurs only with the decorated method and zero-argument super(). Then trace attrs.define() handling of decorated methods and add a regression test for B().f(); done means the example works without changing super() to super(B, self).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100