Skip to content

Non-overlapping identity check when left operand is not optional and right operand is None #11888

@sami-evangelista

Description

@sami-evangelista

mypy does not complain on line 4 of this code:

i: int = 1
s: str = 'hi'
i is s  # error: Non-overlapping identity check (left operand type: "int", right operand type: "str")
if i is None: # ok
   ...

would it be possible to raise a Non-overlapping identity check error in that case, as in the previous line?

mypy version:

$ mypy --version
mypy 0.930

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions