Add new rule to check for useless quote escapes#8630
Merged
charliermarsh merged 9 commits intoastral-sh:mainfrom Nov 13, 2023
Merged
Add new rule to check for useless quote escapes#8630charliermarsh merged 9 commits intoastral-sh:mainfrom
charliermarsh merged 9 commits intoastral-sh:mainfrom
Conversation
ThiefMaster
commented
Nov 12, 2023
crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs
Outdated
Show resolved
Hide resolved
637452a to
7f0bf50
Compare
ThiefMaster
commented
Nov 12, 2023
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| Q004 | 1 | 1 | 0 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
Member
|
Haven't reviewed the code yet, but the ecosystem check seems to be flagging some cases like |
Contributor
Author
|
Yeah, just noticed that I'm not checking for escaped backslashes - already on it |
Member
|
Awesome, thanks @ThiefMaster! |
bc64a73 to
ac6b617
Compare
ThiefMaster
commented
Nov 12, 2023
crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs
Outdated
Show resolved
Hide resolved
ac6b617 to
e90a3bf
Compare
Contributor
Author
|
Ecosystems looks much better now. The one new violation is actually correct since those quotes there should not be escaped. |
e90a3bf to
e188954
Compare
Contributor
Author
|
The mkdocs CI failure seems unrelated (it didn't fail until I rebased to the latest master). |
e188954 to
7b36ebe
Compare
7b36ebe to
65163b5
Compare
ThiefMaster
commented
Nov 13, 2023
crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_escaped_unnecessary.py
Outdated
Show resolved
Hide resolved
charliermarsh
approved these changes
Nov 13, 2023
be9cf4e to
c6de455
Compare
charliermarsh
approved these changes
Nov 13, 2023
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.
When using the autofixer for
Q000it 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.
I used
Q100to avoid ocnflicts withQ00xrulesflake8-quotesmight add (even though it's not very actively maintained)fixes #8617