-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
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
Expected Behaviour
- Ability to type check abstract property
getters
andsetters
- The intention is to have an interface-like design using properties
Actual Behaviour & Repro Case
Python Code
from abc import abstractmethod
class A:
@property # error occurs here
@abstractmethod
def foo(self) -> int:
pass
@foo.setter # type: ignore
@abstractmethod
def foo(self, value: int) -> None:
pass
Mypy CLI
mypy --strict
Result
error: Overloaded method has both abstract and non-abstract variants
Notes
- The error message is defined here:
Lines 74 to 75 in a1ace48
INCONSISTENT_ABSTRACT_OVERLOAD = \ 'Overloaded method has both abstract and non-abstract variants' - The error is thrown from here:
Lines 329 to 330 in 936ceac
if num_abstract not in (0, len(defn.items)): self.fail(messages.INCONSISTENT_ABSTRACT_OVERLOAD, defn) - Removing
# type: ignore
from@foo.setter
causesmypy
to throwerror: Decorated property not supported
, just as in Decorated property not supported #1362
Related Issues
Current Solution
- Silence the error with
@property # type: ignore
maxfischer2781, veox, pi9min, solstice333, mattshep and 7 more
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