Skip to content

inferred type of "(cond and a) or b" #1477

Closed
@rwbarton

Description

@rwbarton

If cond: Bool, a: A, and b: B, then mypy thinks (cond and a) or b has type Union[bool, A, B]. But in fact the type should just be Union[A, B]. The only way (cond and a) or b can be a bool is for it to be (cond and a), and for that to be truth-y; but in that case (cond and a) would have type A, and never type bool (from cond).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions