-
Notifications
You must be signed in to change notification settings - Fork 943
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
Q000 fixer does not remove obsolete backslash-escape inside string after changing quotes #8617
Comments
Agreed, it makes sense to remove redundant escapes when converting quote styles. (I consider this low-priority since we're more focused on string normalization in the formatter, but I would gladly accept a contribution here.) |
I would gladly use the formatter if it had an option to only apply certain changes (such as quote style) since I really do not like what black does to my codebase, so I don't think I'd want to use the ruff formatter either. :/ For implementing a fix, would you do it as part of this fixer of as a new rule (if yes: where, since it's not in the original flake8-quotes) that only looks at unnecessary escapes in a string? |
I hear you! While I don't share that opinion for my own code :) I do understand why saying "Just use the formatter" doesn't close out the issue. I'm more just trying to convey that for our own prioritization, we're more focused on improving the formatter's string normalization than investing further in the linter's string-formatting rules (right now, we basically have to maintain these two separate implementations). I think easiest would be to add a new rule to the |
When using the autofixer for `Q000` it does not remove the backslashes from quotes that no longer need escaping. This new rule checks for such backslashes (regardless whether they come from the autofixer or not) and can remove them. fixes #8617
ruff.toml:
Code:
ruff output:
And after running with
--fix
added:While not invalid, this is ugly - in particular since
avoid-escape
is enabled. It should have been this:The text was updated successfully, but these errors were encountered: