mypy
mypy copied to clipboard
no error when overriding property with incompatible return type when the overridden property has a setter that's decorated with a `contextmanager`
from contextlib import contextmanager
from typing import Iterator
@contextmanager
def foo() -> Iterator[None]:
yield
class Bar:
@property
def asdf(self) -> int:
return 2
class Baz(Bar):
@property
def asdf(self) -> str: # no error
return ""
@asdf.setter
@foo()
def asdf(self, new_value): ...
removing the @foo() decorator makes the error appear:
main.py:16: error: Signature of "asdf" incompatible with supertype "Bar" [override]
main.py:16: note: Superclass:
main.py:16: note: int
main.py:16: note: Subclass:
main.py:16: note: str
Found 1 error in 1 file (checked 1 source file)