Detect repeated signed and complex dictionary keys - #26007
Merged
Conversation
charliermarsh
force-pushed
the
charlie/f601-numeric-keys
branch
from
June 15, 2026 15:03
1cba3b6 to
79e3a8c
Compare
|
ntBre
approved these changes
Jun 15, 2026
charliermarsh
force-pushed
the
charlie/hash
branch
from
June 15, 2026 19:06
646f36c to
3727d68
Compare
charliermarsh
force-pushed
the
charlie/f601-numeric-keys
branch
2 times, most recently
from
June 15, 2026 19:23
7d15c18 to
cb45445
Compare
charliermarsh
enabled auto-merge (squash)
June 15, 2026 19:23
charliermarsh
force-pushed
the
charlie/f601-numeric-keys
branch
from
June 15, 2026 19:28
cb45445 to
ef7f8c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
F601 hashes dictionary keys with
HashableExpr, but it only reported duplicate literal AST nodes, tuples, and f-strings. Signed numbers and constructed complex numbers are represented as unary or binary expressions, so the numeric-key equivalences added in #25982 were order-dependent:{False: 1, -0: 2} # missed {-0: 1, False: 2} # reportedThis recognizes signed numeric and constructed complex expressions as literal keys without treating arbitrary unary or binary expressions as literals. F601 now reports the later key in either order for both
False/-0andTrue/1 + 0j.