-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid syntax error via invalid ur string prefix
- Loading branch information
1 parent
22d8a98
commit a0c22d8
Showing
7 changed files
with
303 additions
and
174 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 |
---|---|---|
|
@@ -43,3 +43,6 @@ def f(): | |
''' # noqa | ||
|
||
regex = '\\\_' | ||
|
||
#: W605:1:7 | ||
u'foo\ bar' |
42 changes: 28 additions & 14 deletions
42
crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_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 |
---|---|---|
@@ -1,40 +1,54 @@ | ||
# Same as `W605_0.py` but using f-strings instead. | ||
|
||
#: W605:1:10 | ||
regex = '\.png$' | ||
regex = f'\.png$' | ||
|
||
#: W605:2:1 | ||
regex = ''' | ||
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' | ||
|
||
def f(): | ||
#: W605:1:11 | ||
return'\.png$' | ||
|
||
#: Okay | ||
regex = r'\.png$' | ||
regex = '\\.png$' | ||
regex = r''' | ||
regex = fr'\.png$' | ||
regex = f'\\.png$' | ||
regex = fr''' | ||
\.png$ | ||
''' | ||
regex = r''' | ||
regex = fr''' | ||
\\.png$ | ||
''' | ||
s = '\\' | ||
regex = '\w' # noqa | ||
regex = ''' | ||
s = f'\\' | ||
regex = f'\w' # noqa | ||
regex = f''' | ||
\w | ||
''' # noqa | ||
|
||
regex = f'\\\_' | ||
value = f'\{{1}}' | ||
value = f'\{1}' | ||
value = f'{1:\}' | ||
value = f"{f"\{1}"}" | ||
value = rf"{f"\{1}"}" | ||
|
||
# Okay | ||
value = rf'\{{1}}' | ||
value = rf'\{1}' | ||
value = rf'{1:\}' | ||
value = f"{rf"\{1}"}" |
54 changes: 0 additions & 54 deletions
54
crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_2.py
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.