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
Bug Report
At runtime, comparing an instance of
Pathtostrseems to be always negative, i.e., they don't overlap in terms of comparison.Using the
--strict-equalitytypically errors in such cases that are non-overlapping and cannot possibly yieldTrue. This mechanism doesn't seem to work forPathandstr, allowing to silently let such bugs pass.To Reproduce
The following code has a bug, because the
Pathtostrdoes not work as intendedExpected Behavior
I'd have expected a type error similar to the one for comparing e.g.
strtoint:Actual Behavior
--strict-equalityhas no effect here, and misses the bug.Your Environment
--strict-equalitymypy.ini(and other config files): -