Property setter not accepted if not next to getter #1465
Copy link
Copy link
Open
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributes
Description
The following code incorrectly raises an error:
class Config(object):
@property
def my_proprty(self):
return None
def _other(self):
pass
@my_proprty.setter
def my_proprty(self, val):
pass
Error:
mypytest.py: note: In class "Config":
mypytest.py:12: error: Callable[[Any], Any] has no attribute "setter"
Commenting out the _other method will fix the error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributes
Activity
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
Make mypy succeed with imports on master.py
ilevkivskyi commentedon Jun 4, 2017
#1713 has another example and some ideas.
levsa commentedon Aug 30, 2017
What is the status of this issue? #1713 is closed as duplicate of this issue.
JukkaL commentedon Aug 30, 2017
We don't have immediate plans for fix this issue, but we are happy to receive a PR.
[-]Wrong error for @smth.setter property[/-][+]Property setter not accepted if not next to getter[/+]levsa commentedon Aug 30, 2017
I had missed that moving the setter next to getter solves the problem, which is good enough. Thanks for the update!
30 remaining items
samskiter commentedon May 27, 2023
Thanks for posting this - also struggling with this. Is there any known workaround? Specifically I wanted to override a property setter.
asarkar commentedon Sep 23, 2023
"No attribute" along with "Untyped decorator" error.
Running mypy with
--strictgenerates:Line 28 happens to be the
@Cell.value.setter.RF: annotate entries.py, fix a string format in test
RF: annotate entries.py, fix a string format in test
Workaround for python/mypy#1465
Enable type hint checking (#5956)
🏷️ Fixing mypy errors
Fix false positive when @Property getter and setter are non-adjacent
Add type hints
Add type hints
Add type hints
Add type hints
Add type hints
Add type hints
Add type hints