Non-overlapping identity check when left operand is not optional and right operand is None
Open
Nobody has claimed this yet.
feature
topic-overlap
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported snippet with the mypy CLI, starting from the identity-check diagnostic behavior described in the issue. Trace how comparisons against None are handled and add a regression test for a non-optional left operand; done when the None comparison reports a non-overlapping identity check without regressing the existing cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100