Open
Description
Bug Report
--strict-equality
seems to only work in very reduced cases. In particular, it is not working when comparing strings and uuids.
To Reproduce
import uuid
from typing import TYPE_CHECKING, reveal_type
a = uuid.uuid4()
b = str(a)
if TYPE_CHECKING:
reveal_type(a)
reveal_type(b)
print(a == b)
c = "c"
d = 500
print(c == d)
Expected Behavior
The comparison in line 10 should raise a comparison overlap error. Something like
test_strict_equality.py:10: error: Non-overlapping equality check (left operand type: "str", right operand type: "uuid.UUID") [comparison-overlap]
Actual Behavior
Mypy does not flag the string/UUID comparison as incompatible
test_strict_equality.py:8: note: Revealed type is "uuid.UUID"
test_strict_equality.py:9: note: Revealed type is "builtins.str"
test_strict_equality.py:14: error: Non-overlapping equality check (left operand type: "str", right operand type: "int") [comparison-overlap]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.15.0
- Mypy command-line flags:
--strict-equality --show-error-codes
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.12.9
Metadata
Metadata
Assignees
Labels
No labels