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.
What is the status of this issue? #1713 is closed as duplicate of this issue.
We don't have immediate plans for fix this issue, but we are happy to receive a PR.
I had missed that moving the setter next to getter solves the problem, which is good enough. Thanks for the update!
This also affects subclasses that override properties, e.g.:
class Parent(object):
@property
def foo(self):
return "parent_foo"
class Child(Parent):
@Parent.foo.getter
def foo(self):
return "child_foo"
mypy returns a "Callable[[Any], Any]" has no attribute "getter" error here. In this case, it's obviously not possible to move the two methods to be next to each other.
Most helpful comment
This also affects subclasses that override properties, e.g.:
mypy returns a
"Callable[[Any], Any]" has no attribute "getter"error here. In this case, it's obviously not possible to move the two methods to be next to each other.