-
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.
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary Format bytes string Closes #6064 ## Test Plan Added a fixture based on string's one
- Loading branch information
Showing
9 changed files
with
577 additions
and
89 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/bytes.options.json
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,8 @@ | ||
[ | ||
{ | ||
"quote_style": "double" | ||
}, | ||
{ | ||
"quote_style": "single" | ||
} | ||
] |
120 changes: 120 additions & 0 deletions
120
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/bytes.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,120 @@ | ||
b"' test" | ||
b'" test' | ||
|
||
b"\" test" | ||
b'\' test' | ||
|
||
# Prefer single quotes for string with more double quotes | ||
b"' \" \" '' \" \" '" | ||
|
||
# Prefer double quotes for string with more single quotes | ||
b'\' " " \'\' " " \'' | ||
|
||
# Prefer double quotes for string with equal amount of single and double quotes | ||
b'" \' " " \'\'' | ||
b"' \" '' \" \"" | ||
|
||
b"\\' \"\"" | ||
b'\\\' ""' | ||
|
||
|
||
b"Test" | ||
B"Test" | ||
|
||
rb"Test" | ||
Rb"Test" | ||
|
||
b'This string will not include \ | ||
backslashes or newline characters.' | ||
|
||
if True: | ||
b'This string will not include \ | ||
backslashes or newline characters.' | ||
|
||
b"""Multiline | ||
String \" | ||
""" | ||
|
||
b'''Multiline | ||
String \' | ||
''' | ||
|
||
b'''Multiline | ||
String "" | ||
''' | ||
|
||
b'''Multiline | ||
String """ | ||
''' | ||
|
||
b'''Multiline | ||
String "''' | ||
|
||
b"""Multiline | ||
String ''' | ||
""" | ||
|
||
b"""Multiline | ||
String '""" | ||
|
||
b'''Multiline | ||
String \"\"\" | ||
''' | ||
|
||
# String continuation | ||
|
||
b"Let's" b"start" b"with" b"a" b"simple" b"example" | ||
|
||
b"Let's" b"start" b"with" b"a" b"simple" b"example" b"now repeat after me:" b"I am confident" b"I am confident" b"I am confident" b"I am confident" b"I am confident" | ||
|
||
( | ||
b"Let's" b"start" b"with" b"a" b"simple" b"example" b"now repeat after me:" b"I am confident" b"I am confident" b"I am confident" b"I am confident" b"I am confident" | ||
) | ||
|
||
if ( | ||
a + b"Let's" | ||
b"start" | ||
b"with" | ||
b"a" | ||
b"simple" | ||
b"example" | ||
b"now repeat after me:" | ||
b"I am confident" | ||
b"I am confident" | ||
b"I am confident" | ||
b"I am confident" | ||
b"I am confident" | ||
): | ||
pass | ||
|
||
if b"Let's" b"start" b"with" b"a" b"simple" b"example" b"now repeat after me:" b"I am confident" b"I am confident" b"I am confident" b"I am confident" b"I am confident": | ||
pass | ||
|
||
( | ||
# leading | ||
b"a" # trailing part comment | ||
|
||
# leading part comment | ||
|
||
b"b" # trailing second part comment | ||
# trailing | ||
) | ||
|
||
test_particular = [ | ||
# squares | ||
b'1.00000000100000000025', | ||
b'1.0000000000000000000000000100000000000000000000000' #... | ||
b'00025', | ||
b'1.0000000000000000000000000000000000000000000010000' #... | ||
b'0000000000000000000000000000000000000000025', | ||
] | ||
|
||
# Parenthesized string continuation with messed up indentation | ||
{ | ||
"key": ( | ||
[], | ||
b'a' | ||
b'b' | ||
b'c' | ||
) | ||
} |
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
Oops, something went wrong.