Closed
Description
I'm raising a bug.
It's also posted on SO at https://stackoverflow.com/q/52744713/5986907
I get
$ mypy file.py
python.py:34: error: Signature of "fn" incompatible with supertype "B"
for file.py
from typing import Callable, TypeVar, cast
T = TypeVar('T')
def dec(f: Callable[..., T]) -> T:
def p(self):
return getattr(self, '_' + f.__name__)
return cast(T, property(p))
class X:
pass
class Y(X):
pass
class A:
_fn = Y()
class B(A):
@dec
def fn(self) -> X:
return X()
class C(B):
@dec
def fn(self) -> Y:
return Y()
I'd expect there to be no error as Y is a subclass of X.
I've tried this with mypy 0.630 and Python 3.5.2, 3.6.6 and 3.7.0. Also with mypy git master for python 3.5.2 and 3.7.0
It's possible these are related but I couldn't quite connect them
#220
#4430