-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize '\r' in string literals to '\n'
<!-- 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 This PR normalizes line endings inside of strings to `\n` as required by the printer. <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan I added a new test using `\r\n` and ran the ecosystem check. There are no remaining end of line panics. https://gist.github.com/MichaReiser/8f36b1391ca7b48475b3a4f592d74ff4 <!-- How was it tested? -->
- Loading branch information
1 parent
dc65007
commit f9129e4
Showing
5 changed files
with
95 additions
and
43 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/.editorconfig
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,2 @@ | ||
[*.py] | ||
end_of_line = crlf |
1 change: 1 addition & 0 deletions
1
crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/.gitattributes
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 @@ | ||
* text=auto eol=crlf |
6 changes: 6 additions & 0 deletions
6
crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/string.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,6 @@ | ||
'This string will not include \ | ||
backslashes or newline characters.' | ||
|
||
"""Multiline | ||
String \" | ||
""" |
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
26 changes: 26 additions & 0 deletions
26
crates/ruff_python_formatter/tests/snapshots/format@carriage_return__string.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,26 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/string.py | ||
--- | ||
## Input | ||
```py | ||
'This string will not include \ | ||
backslashes or newline characters.' | ||
"""Multiline | ||
String \" | ||
""" | ||
``` | ||
|
||
## Output | ||
```py | ||
"This string will not include \ | ||
backslashes or newline characters." | ||
"""Multiline | ||
String \" | ||
""" | ||
``` | ||
|
||
|
||
|