Skip to content

"Overloaded function signatures overlap with incompatible return types" false positive when there can be a subtype of both return types #13611

@DetachHead

Description

@DetachHead
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions