-
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
] Add support for more patterns (RUF055
)
- Loading branch information
Showing
6 changed files
with
288 additions
and
57 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
27 changes: 27 additions & 0 deletions
27
crates/ruff_linter/resources/test/fixtures/ruff/RUF055_2.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,27 @@ | ||
"""Patterns that don't just involve the call, but rather the parent expression""" | ||
import re | ||
|
||
s = "str" | ||
|
||
# this should be replaced with `"abc" not in s` | ||
re.search("abc", s) is None | ||
|
||
|
||
# this shuold be replaced with `"abc" in s` | ||
re.search("abc", s) is not None | ||
|
||
|
||
# this should be replaced with `not s.startswith("abc")` | ||
re.match("abc", s) is None | ||
|
||
|
||
# this should be replaced with `s.startswith("abc")` | ||
re.match("abc", s) is not None | ||
|
||
|
||
# this should be replaced with `s != "abc"` | ||
re.fullmatch("abc", s) is None | ||
|
||
|
||
# this should be replaced with `s == "abc"` | ||
re.fullmatch("abc", s) is not None |
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
Oops, something went wrong.