You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
strict equality check fails to detect non-overlap of str and Path #16231
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
frompathlibimportPatha="/foo"b=Path("/foo")
ifa==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:
Activity
AlexWaygood commentedon Oct 6, 2023
Fixed in python/typeshed#10662 (but you might have to wait until mypy 1.7 for the fix, not sure it'll make mypy 1.6)
AlexWaygood commentedon Oct 6, 2023
Fun fact: merging that typeshed change into mypy uncovered a bug in mypy itself: take a look at the last commit in #16121