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? -->
This commit is contained in:
Micha Reiser 2023-06-30 10:13:23 +02:00 committed by GitHub
parent dc65007fe9
commit f9129e435a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 41 deletions

View file

@ -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 \"
"""
```