KotlinIsland / KotlinIsland/basedmypy

`None` comparison overlap is wrong

Open
#676 0 comments 0 reactions 0 assignees View on GitHub
problem :trollface:
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

```py
a: int | None
b: str | None
a == b # Non-overlapping equality check (left operand type: "int | None", right operand type: "str | None") [comparison-overlap]
```
but it's still useful :trollface: :
Although this error message is flat out wrong, I do see the inadvertent value here: `NoneType` is a singleton inhabitant type, so it is more likely accidental, rather than intentionally checking that both values are `None`. If I wanted that I would write:
```py
a is None and b is None
```
perhaps:
```py
a == b # warning: the operands only overlap with "None", consider writing "a is None and b is None" [none-overlap]
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the Python snippet and inspect the code path that emits the `comparison-overlap` diagnostic. Done means the checker no longer reports the operands as wholly non-overlapping when their only overlap is `None`, with the intended `None`-specific warning behavior agreed and covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.