mypy
mypy copied to clipboard
"Overloaded function signatures overlap with incompatible return types" false positive when there can be a subtypeof both return types
from typing import overload, Literal
class A: ...
class B: ...
class C(A, B): ...
@overload
def foo(a: Literal[True], b: Literal[True]) -> C: ...
@overload
def foo(a: Literal[True], b: bool) -> A: ... # error: Overloaded function signatures 2 and 3 overlap with incompatible return types [misc]
@overload
def foo(a: bool, b: Literal[True]) -> B: ...
def foo(a: bool, b: bool) -> object: ...