-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
ruff
] Extend unnecessary-regular-expression to non-literal strings…
… (`RUF055`) (#14679) Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
- Loading branch information
1 parent
81bfcc9
commit 62e358e
Showing
7 changed files
with
387 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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
17 changes: 17 additions & 0 deletions
17
crates/ruff_linter/resources/test/fixtures/ruff/RUF055_1.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Test that RUF055 can follow a single str assignment for both the pattern and | ||
the replacement argument to re.sub | ||
""" | ||
|
||
import re | ||
|
||
pat1 = "needle" | ||
|
||
re.sub(pat1, "", haystack) | ||
|
||
# aliases are not followed, so this one should not trigger the rule | ||
if pat4 := pat1: | ||
re.sub(pat4, "", haystack) | ||
|
||
# also works for the `repl` argument in sub | ||
repl = "new" | ||
re.sub(r"abc", repl, haystack) |
This file contains 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
This file contains 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
129 changes: 0 additions & 129 deletions
129
.../src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055.py.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.