-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update UP032
to handle repeated indices/keywords
#6217
Comments
Hey, thanks for reporting. This matches the behavior of |
@dhruvmanila Thanks for the comment! I found this code:
I'm investigating why |
This comment might be the reason:
For example: "{0} and {0} and {0}".format(xxxxxxxxxxxxxxxxxxx) is obviously shorter than: f"{xxxxxxxxxxxxxxxxxxx} and {xxxxxxxxxxxxxxxxxxx} and {xxxxxxxxxxxxxxxxxxx}" |
Hey, thanks for looking. Yes, the first example is shorter than the fix but if the fix is under the ruff/crates/ruff/src/rules/pyupgrade/rules/f_strings.rs Lines 343 to 357 in d9e84c5
|
Another advantage of the original code is modifiability? Suppose you want to rename |
That's a good point although the LSP rename method can help with that (which most editors have). I think we should implement this. We already have the guard rail in place which avoids auto-fixing if the updated code becomes longer than the |
@dhruvmanila Makes sense. I'll file a PR! |
Closed by #6266 |
Example:
Expected behavior:
UP032
is raised and the code is fixed to:Actual behavior:
UP032
is not raised (playground)The text was updated successfully, but these errors were encountered: