-
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
4a0ad8c
commit b6144d0
Showing
5 changed files
with
213 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Same as `W605_0.py` but using f-strings instead. | ||
|
||
#: W605:1:10 | ||
regex = f'\.png$' | ||
|
||
#: W605:2:1 | ||
regex = f''' | ||
\.png$ | ||
''' | ||
|
||
#: W605:2:6 | ||
f( | ||
f'\_' | ||
) | ||
|
||
#: W605:4:6 | ||
f""" | ||
multi-line | ||
literal | ||
with \_ somewhere | ||
in the middle | ||
""" | ||
|
||
#: W605:1:38 | ||
value = f'new line\nand invalid escape \_ here' | ||
|
||
|
||
#: Okay | ||
regex = fr'\.png$' | ||
regex = f'\\.png$' | ||
regex = fr''' | ||
\.png$ | ||
''' | ||
regex = fr''' | ||
\\.png$ | ||
''' | ||
s = f'\\' | ||
regex = f'\w' # noqa | ||
regex = f''' | ||
\w | ||
''' # noqa | ||
|
||
regex = f'\\\_' |
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
119 changes: 119 additions & 0 deletions
119
...ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_2.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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--- | ||
source: crates/ruff/src/rules/pycodestyle/mod.rs | ||
--- | ||
W605_2.py:4:11: W605 [*] Invalid escape sequence: `\.` | ||
| | ||
3 | #: W605:1:10 | ||
4 | regex = f'\.png$' | ||
| ^^ W605 | ||
5 | | ||
6 | #: W605:2:1 | ||
| | ||
= help: Add backslash to escape sequence | ||
|
||
ℹ Fix | ||
1 1 | # Same as `W605_0.py` but using f-strings instead. | ||
2 2 | | ||
3 3 | #: W605:1:10 | ||
4 |-regex = f'\.png$' | ||
4 |+regex = rf'\.png$' | ||
5 5 | | ||
6 6 | #: W605:2:1 | ||
7 7 | regex = f''' | ||
W605_2.py:8:1: W605 [*] Invalid escape sequence: `\.` | ||
| | ||
6 | #: W605:2:1 | ||
7 | regex = f''' | ||
8 | \.png$ | ||
| ^^ W605 | ||
9 | ''' | ||
| | ||
= help: Add backslash to escape sequence | ||
|
||
ℹ Fix | ||
4 4 | regex = f'\.png$' | ||
5 5 | | ||
6 6 | #: W605:2:1 | ||
7 |-regex = f''' | ||
7 |+regex = rf''' | ||
8 8 | \.png$ | ||
9 9 | ''' | ||
10 10 | | ||
|
||
W605_2.py:13:7: W605 [*] Invalid escape sequence: `\_` | ||
| | ||
11 | #: W605:2:6 | ||
12 | f( | ||
13 | f'\_' | ||
| ^^ W605 | ||
14 | ) | ||
| | ||
= help: Add backslash to escape sequence | ||
|
||
ℹ Fix | ||
10 10 | | ||
11 11 | #: W605:2:6 | ||
12 12 | f( | ||
13 |- f'\_' | ||
13 |+ rf'\_' | ||
14 14 | ) | ||
15 15 | | ||
16 16 | #: W605:4:6 | ||
|
||
W605_2.py:20:6: W605 [*] Invalid escape sequence: `\_` | ||
| | ||
18 | multi-line | ||
19 | literal | ||
20 | with \_ somewhere | ||
| ^^ W605 | ||
21 | in the middle | ||
22 | """ | ||
| | ||
= help: Add backslash to escape sequence | ||
|
||
ℹ Fix | ||
14 14 | ) | ||
15 15 | | ||
16 16 | #: W605:4:6 | ||
17 |-f""" | ||
17 |+rf""" | ||
18 18 | multi-line | ||
19 19 | literal | ||
20 20 | with \_ somewhere | ||
|
||
W605_2.py:25:40: W605 [*] Invalid escape sequence: `\_` | ||
| | ||
24 | #: W605:1:38 | ||
25 | value = f'new line\nand invalid escape \_ here' | ||
| ^^ W605 | ||
| | ||
= help: Add backslash to escape sequence | ||
|
||
ℹ Fix | ||
22 22 | """ | ||
23 23 | | ||
24 24 | #: W605:1:38 | ||
25 |-value = f'new line\nand invalid escape \_ here' | ||
25 |+value = f'new line\nand invalid escape \\_ here' | ||
26 26 | | ||
27 27 | | ||
28 28 | #: Okay | ||
|
||
W605_2.py:43:13: W605 [*] Invalid escape sequence: `\_` | ||
| | ||
41 | ''' # noqa | ||
42 | | ||
43 | regex = f'\\\_' | ||
| ^^ W605 | ||
| | ||
= help: Add backslash to escape sequence | ||
|
||
ℹ Fix | ||
40 40 | \w | ||
41 41 | ''' # noqa | ||
42 42 | | ||
43 |-regex = f'\\\_' | ||
43 |+regex = f'\\\\_' | ||
|
||
|