Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F601: Duplicated keys with different parenthesisation fixed incorrectly #4897

Closed
Tracked by #4972
addisoncrump opened this issue Jun 6, 2023 · 0 comments · Fixed by #7559
Closed
Tracked by #4972

F601: Duplicated keys with different parenthesisation fixed incorrectly #4897

addisoncrump opened this issue Jun 6, 2023 · 0 comments · Fixed by #7559
Assignees
Labels
bug Something isn't working fixes Related to suggested fixes for violations

Comments

@addisoncrump
Copy link
Contributor

This is a case which I believe is potentially indicative of other bugs with the F601 fix.

Duplicated keys are merged by Ruff in the case of equal values, but the method by which this is done leads to a strange error in the case of different parenthesisation:

t={"x":"test123", "x":("test123")}

And the applied diff:

Fixed source has a syntax error where the source document does not. This is a bug in one of the generated fixes:
<filename>:1:17: E999 SyntaxError: unexpected token ')'
  |
1 | t={"x":"test123")}
  |                 ^ E999
  |


Last generated fixes:
<filename>:1:19: F601 [*] Dictionary key literal `"x"` repeated
  |
1 | t={"x":"test123", "x":("test123")}
  |                   ^^^ F601
  |
  = help: Remove repeated key literal `"x"`

ℹ Suggested fix
1   |-t={"x":"test123", "x":("test123")}
  1 |+t={"x":"test123")}


Source with applied fixes:
t={"x":"test123")}

Discovered by #4822.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants