-
-
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-normal
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
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-normal