-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Closed as not planned
Copy link
Labels
bugmypy got something wrongmypy got something wrongtopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributes
Description
Bug Report
mypy does not properly verify types while overriding property setters
To Reproduce
Tryto override a property setter in a subclass according to how it is described in https://stackoverflow.com/questions/3336767/overriding-inherited-properties-getters-and-setters-in-python:
class A:
def __init__(self):
self._attr: str = ''
@property
def attr(self) -> str:
return self._attr
@attr.setter
def attr(self, value: str) -> None:
self._attr = value
class B(A):
@A.attr.setter
def attr(self, value: str) -> None:
A.attr.fset(self, value)
Expected Behavior
No errors from mypy
Actual Behavior
mypy fails typecheck with the following errors:
error: overloaded function has no attribute "setter"
and
error: overloaded function has no attribute "fset"
on the following lines:
@A.attr.setter
and A.attr.fset(self, value)
Your Environment
- Mypy version used: 0.961
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.9.9
- Operating system and version: macOS 11.6.5
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributes