python-attrs / python-attrs/attrs
`__getattr__` in child class gets called when mixed with `cached_property`
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
from functools import cached_property
from attrs import define
@define
class Bob:
@cached_property
def howdy(self):
return 3
class Sup(Bob):
def __getattr__(self, name):
raise AttributeError(name)
b = Sup()
# reaches __getattr__ where I raise AttributeError
b.howdy
This previously did not error. I would expect __getattr__ to not be called since the attribute exists.
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
Start by running the Python reproduction from the issue with attrs and functools.cached_property. Trace how the inherited cached_property is resolved when Sup defines getattr, then add a regression test for b.howdy. Done means the existing cached property is returned without calling Sup.getattr.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100