basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

inferred overload return types don't work with generics in some cases

Open DetachHead opened this issue 1 year ago • 2 comments

@overload
def foo(value: str) -> int: ...


@overload
def foo[T](value: T) -> T: ...


def foo[T](value: T | str):
    if isinstance(value, str):
        return 1
    return value  # Incompatible return value type (got "T@foo", expected "int | T@foo")

DetachHead avatar Aug 19 '24 05:08 DetachHead

duplicate of #385?

KotlinIsland avatar Aug 19 '24 05:08 KotlinIsland

dont think so, this issue seems to have been introduced in the latest release

DetachHead avatar Aug 19 '24 05:08 DetachHead

i think it is the same underlying issue, i'm going to merge it

KotlinIsland avatar Aug 28 '24 12:08 KotlinIsland