basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

`None` comparison overlap is wrong

Open KotlinIsland opened this issue 1 year ago • 0 comments

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:

a is None and b is None

perhaps:

a == b  # warning: the operands only overlap with "None", consider writing "a is None and b is None"  [none-overlap]

KotlinIsland avatar Apr 25 '24 23:04 KotlinIsland