Closed as not planned
Description
Bug Report
At runtime, comparing an instance of Path
to str
seems to be always negative, i.e., they don't overlap in terms of comparison.
Using the --strict-equality
typically errors in such cases that are non-overlapping and cannot possibly yield True
. This mechanism doesn't seem to work for Path
and str
, allowing to silently let such bugs pass.
To Reproduce
The following code has a bug, because the Path
to str
does not work as intended
from pathlib import Path
a = "/foo"
b = Path("/foo")
if a == b: # can never be true
...
Expected Behavior
I'd have expected a type error similar to the one for comparing e.g. str
to int
:
error: Non-overlapping equality check (left operand type: "str", right operand type: "Path") [comparison-overlap]
Actual Behavior
--strict-equality
has no effect here, and misses the bug.
Your Environment
- Mypy version used: 1.5.1
- Mypy command-line flags:
--strict-equality
- Mypy configuration options from
mypy.ini
(and other config files): - - Python version used: 3.11