Skip to content

(🐞) generics not resolving correctly when multiple TypeVars don't meet the expected type #17553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KotlinIsland opened this issue Jul 22, 2024 · 0 comments · May be fixed by #18976
Open
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

from typing import TypeVar

T1 = TypeVar("T1")
T2 = TypeVar("T2")


def f(t1: T1, t2: T2) -> T1 | T2:
    return t1


a: int = f(1, None) or 1  # error: Argument 2 to "f" has incompatible type "None"; expected "int"  [arg-type]

def f1(t1: T1, t2: T1) -> T1:
    return t1

b: int = f1(1, None) or 1  # no error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
1 participant