ruff
8de183b9 - Detect equivalent numeric mapping keys (#26009)

Commit
24 days ago
Detect equivalent numeric mapping keys (#26009) ## Summary Mapping-pattern duplicate detection and F601 compare keys through `HashableExpr`, but numeric normalization previously only recognized values equivalent to `True` or `False`. This meant that other values Python treats as the same dictionary key were considered distinct: ```python match value: case {2: first, 2.0: second}: ... ``` This adds a dedicated numeric representation for integer, float, boolean, and complex literals so that exactly integral floats compare with equivalent integers, including signed forms and zero-imaginary complex values. Tuple normalization is limited to statically known values so dynamic tuple elements do not introduce false-positive F601 diagnostics. Numeric normalization uses the existing `u64` integer representation. Larger integers retain structural comparison, avoiding arbitrary-precision conversion in parser and linter hot paths.
Author
Parents
Loading