AttributeError 'did you mean' suggestions don't appear for properties without a setter
Open
Nobody has claimed this yet.
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
class A:
@property
def computed_a(self):
return 2
@property
def computed_b(self):
return 3
@computed_b.setter
def computed_b(self, val):
print('set!')
a = A()
a.computed_a = 12 # typo
When running this, I would expect to get AttributeError: ... Did you mean: 'computed_b', but I'm not getting a suggestion. I think it's because the AttributeError that property.__set__ raises doesn't have .obj and .name set.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
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
Reproduce the reported property-assignment example on the CPython main branch and inspect the implementation of property.set and AttributeError suggestion handling. The fix is complete when assigning to the read-only computed_a property produces an AttributeError with a relevant “Did you mean” suggestion, without changing the setter case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100