Closed
Description
Bug Report
Unexpected typing failure when subclassing protocol.
To Reproduce
mypy --strict f.py
f.py
:
import typing
class B(typing.Protocol):
field1: float
class D(B):
@property
def field1(self) -> float: return 0
@field1.setter
def field1(self, v: float) -> None: pass
class E:
@property
def field1(self) -> float: return 0
@field1.setter
def field1(self, v: float) -> None: pass
Expected Behavior
Both classes, D
and E
, should pass type checking.
Actual Behavior
The D
class fails type checking:
f.py:7: error: Signature of "field1" incompatible with supertype "B"
f.py:8: error: Signature of "field1" incompatible with supertype "B"
Found 2 errors in 1 file (checked 1 source file)
Your Environment
Multiple environments.
% mypy --version
mypy 0.982 (compiled: yes)