Skip to content
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

Regression in 1.7: mypy loses truthiness constraint for union containing tuple #16748

Open
hauntsaninja opened this issue Jan 5, 2024 · 0 comments
Labels
bug mypy got something wrong topic-type-narrowing Conditional type narrowing / binder

Comments

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jan 5, 2024

def f(x: bool | tuple[int, int]):
    if x:
        if x is True or x[0]:
            pass

Gives:

main.py:3: error: Value of type "Literal[False] | tuple[int, int]" is not indexable  [index]

This error is newly reported after #16237

@hauntsaninja hauntsaninja added the bug mypy got something wrong label Jan 5, 2024
@hauntsaninja hauntsaninja changed the title mypy loses truthiness constraint in nested if statement Regression in 1.7: mypy loses truthiness constraint in nested if statement Jan 5, 2024
@hauntsaninja hauntsaninja changed the title Regression in 1.7: mypy loses truthiness constraint in nested if statement Regression in 1.7: mypy loses truthiness constraint for union containing tuple Jan 5, 2024
@AlexWaygood AlexWaygood added the topic-type-narrowing Conditional type narrowing / binder label Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-type-narrowing Conditional type narrowing / binder
Projects
None yet
Development

No branches or pull requests

2 participants