-
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.
- Loading branch information
1 parent
6644a9b
commit 7a85780
Showing
7 changed files
with
91 additions
and
42 deletions.
There are no files selected for viewing
26 changes: 19 additions & 7 deletions
26
crates/ruff_linter/resources/test/fixtures/refurb/FURB167.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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
import re | ||
def func(): | ||
import re | ||
|
||
# BAD: | ||
if re.match("^hello", "hello world", re.I): | ||
pass | ||
# OK | ||
if re.match("^hello", "hello world", re.IGNORECASE): | ||
pass | ||
|
||
|
||
# GOOD: | ||
if re.match("^hello", "hello world", re.IGNORECASE): | ||
pass | ||
def func(): | ||
import re | ||
|
||
# FURB167 | ||
if re.match("^hello", "hello world", re.I): | ||
pass | ||
|
||
|
||
def func(): | ||
from re import match, I | ||
|
||
# FURB167 | ||
if match("^hello", "hello world", I): | ||
pass |
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
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
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
54 changes: 38 additions & 16 deletions
54
...ter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap
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 |
---|---|---|
@@ -1,23 +1,45 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/refurb/mod.rs | ||
--- | ||
FURB167.py:4:38: FURB167 [*] Use of shorthand `re.I` | ||
| | ||
3 | # BAD: | ||
4 | if re.match("^hello", "hello world", re.I): | ||
| ^^^^ FURB167 | ||
5 | pass | ||
| | ||
= help: Replace with `re.IGNORECASE` | ||
FURB167.py:13:42: FURB167 [*] Use of shorthand `re.I` | ||
| | ||
12 | # FURB167 | ||
13 | if re.match("^hello", "hello world", re.I): | ||
| ^^^^ FURB167 | ||
14 | pass | ||
| | ||
= help: Replace with `re.IGNORECASE` | ||
|
||
ℹ Safe fix | ||
1 1 | import re | ||
2 2 | | ||
3 3 | # BAD: | ||
4 |-if re.match("^hello", "hello world", re.I): | ||
4 |+if re.match("^hello", "hello world", re.IGNORECASE): | ||
5 5 | pass | ||
6 6 | | ||
7 7 | | ||
10 10 | import re | ||
11 11 | | ||
12 12 | # FURB167 | ||
13 |- if re.match("^hello", "hello world", re.I): | ||
13 |+ if re.match("^hello", "hello world", re.IGNORECASE): | ||
14 14 | pass | ||
15 15 | | ||
16 16 | | ||
|
||
FURB167.py:21:39: FURB167 [*] Use of shorthand `re.I` | ||
| | ||
20 | # FURB167 | ||
21 | if match("^hello", "hello world", I): | ||
| ^ FURB167 | ||
22 | pass | ||
| | ||
= help: Replace with `re.IGNORECASE` | ||
|
||
ℹ Safe fix | ||
1 |+import re | ||
1 2 | def func(): | ||
2 3 | import re | ||
3 4 | | ||
-------------------------------------------------------------------------------- | ||
18 19 | from re import match, I | ||
19 20 | | ||
20 21 | # FURB167 | ||
21 |- if match("^hello", "hello world", I): | ||
22 |+ if match("^hello", "hello world", re.IGNORECASE): | ||
22 23 | pass | ||
|
||
|