-
-
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-overloads
Description
I've noticed this problem, very similar to #3262 , except with overloaded operators.
Originally, #3262 made it so that code like this:
from typing import overload
class A:
def f(self, x : 'A') -> 'A': ...
class B(A):
@overload
def f(self, x : 'A') -> 'A': ...
@overload
def f(self, x : 'B') -> 'B' : ...
Wouldn't typecheck.
#3263 appears to have fixed this. Unfortunately, while this works for normal method signatures, it doesn't appear to work for overloaded operators. So the very similar code:
from typing import overload
class A:
def __add__(self, x : 'A') -> 'A': ...
class B(A):
@overload
def __add__(self, x : 'A') -> 'A': ...
@overload
def __add__(self, x : 'B') -> 'B' : ...
Still fails to typecheck, with the error message:
test.pyi:7: error: Signature of "__add__" incompatible with supertype "A"
I can't think of any reason why this should be a problem with operators, although maybe someone else can explain.
I'm on Python 3.6.3 and MyPy 0.600+dev (master branch from git)
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-overloads