Skip to content

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

Open
@hauntsaninja

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-narrowingConditional type narrowing / binder

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions