-
-
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-0-hightopic-overloadstopic-union-types
Description
This fragment derived from production code causes a false positive:
def f(): pass # No annotation
t = False
t &= f() and True # Incompatible types in assignment
# (expression has type "int", variable has type "bool")
Here's a self-contained repro:
from typing import overload, Union, Any
class C:
def f(self, other: C) -> C: ...
class D(C):
@overload # type: ignore
def f(self, other: D) -> D: ...
@overload
def f(self, other: C) -> C: ...
def f(self, other): ...
x: D
y: Union[D, Any]
reveal_type(x.f(y)) # C
I'd expect the inferred type for x.f(y)
to be Union[D, Any]
(or maybe D
, though it's slightly less correct arguably).
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-hightopic-overloadstopic-union-types