mypy icon indicating copy to clipboard operation
mypy copied to clipboard

"Overloaded function signatures overlap with incompatible return types" false positive when there can be a subtypeof both return types

Open DetachHead opened this issue 3 years ago • 0 comments

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: ...

playground

DetachHead avatar Sep 05 '22 06:09 DetachHead