mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
Don't add chaperone space after escaped quote in triple quote (#17216)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
1a3b73720c
commit
1aad180aae
5 changed files with 307 additions and 11 deletions
|
@ -0,0 +1,195 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_chaperones.py
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
def a1():
|
||||
"""Needs chaperone\\" """
|
||||
|
||||
def a2():
|
||||
"""Needs chaperone\\\ """
|
||||
|
||||
def a3():
|
||||
"""Needs chaperone" """
|
||||
|
||||
def a4():
|
||||
"""Needs chaperone\ """
|
||||
|
||||
def a5():
|
||||
"""Needs chaperone\\\\\ """
|
||||
|
||||
def a6():
|
||||
"""Needs chaperone\"" """
|
||||
|
||||
def a7():
|
||||
"""Doesn't need chaperone\""""
|
||||
|
||||
def a8():
|
||||
"""Doesn't need chaperone\'"""
|
||||
|
||||
def a9():
|
||||
"""Doesn't need chaperone\\\""""
|
||||
|
||||
def a10():
|
||||
"""Doesn't need chaperone\\\'"""
|
||||
|
||||
def a11():
|
||||
"""Doesn't need chaperone; all slashes escaped\\\\"""
|
||||
|
||||
def a12():
|
||||
"""Doesn't need chaperone\\"""
|
||||
|
||||
def a12():
|
||||
"""Doesn't need "chaperone" with contained quotes"""
|
||||
|
||||
def a13():
|
||||
"""Doesn't need chaperone\\\"\"\""""
|
||||
|
||||
def a14():
|
||||
"""Multiline docstring
|
||||
doesn't need chaperone
|
||||
"""
|
||||
|
||||
def a15():
|
||||
"""Multiline docstring
|
||||
doesn't need chaperone\
|
||||
"""
|
||||
|
||||
def a16():
|
||||
"""Multiline docstring with
|
||||
odd number of backslashes don't need chaperone\\\
|
||||
"""
|
||||
|
||||
def a17():
|
||||
"""Multiline docstring with
|
||||
even number of backslashes don't need chaperone\\\\
|
||||
"""
|
||||
|
||||
def a18():
|
||||
r"""Raw multiline docstring
|
||||
doesn't need chaperone\
|
||||
"""
|
||||
```
|
||||
|
||||
## Output
|
||||
```python
|
||||
def a1():
|
||||
"""Needs chaperone\\" """
|
||||
|
||||
|
||||
def a2():
|
||||
"""Needs chaperone\\\ """
|
||||
|
||||
|
||||
def a3():
|
||||
"""Needs chaperone" """
|
||||
|
||||
|
||||
def a4():
|
||||
"""Needs chaperone\ """
|
||||
|
||||
|
||||
def a5():
|
||||
"""Needs chaperone\\\\\ """
|
||||
|
||||
|
||||
def a6():
|
||||
"""Needs chaperone\"" """
|
||||
|
||||
|
||||
def a7():
|
||||
"""Doesn't need chaperone\" """
|
||||
|
||||
|
||||
def a8():
|
||||
"""Doesn't need chaperone\'"""
|
||||
|
||||
|
||||
def a9():
|
||||
"""Doesn't need chaperone\\\" """
|
||||
|
||||
|
||||
def a10():
|
||||
"""Doesn't need chaperone\\\'"""
|
||||
|
||||
|
||||
def a11():
|
||||
"""Doesn't need chaperone; all slashes escaped\\\\"""
|
||||
|
||||
|
||||
def a12():
|
||||
"""Doesn't need chaperone\\"""
|
||||
|
||||
|
||||
def a12():
|
||||
"""Doesn't need "chaperone" with contained quotes"""
|
||||
|
||||
|
||||
def a13():
|
||||
"""Doesn't need chaperone\\\"\"\" """
|
||||
|
||||
|
||||
def a14():
|
||||
"""Multiline docstring
|
||||
doesn't need chaperone
|
||||
"""
|
||||
|
||||
|
||||
def a15():
|
||||
"""Multiline docstring
|
||||
doesn't need chaperone\
|
||||
"""
|
||||
|
||||
|
||||
def a16():
|
||||
"""Multiline docstring with
|
||||
odd number of backslashes don't need chaperone\\\
|
||||
"""
|
||||
|
||||
|
||||
def a17():
|
||||
"""Multiline docstring with
|
||||
even number of backslashes don't need chaperone\\\\
|
||||
"""
|
||||
|
||||
|
||||
def a18():
|
||||
r"""Raw multiline docstring
|
||||
doesn't need chaperone\
|
||||
"""
|
||||
```
|
||||
|
||||
|
||||
## Preview changes
|
||||
```diff
|
||||
--- Stable
|
||||
+++ Preview
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
def a7():
|
||||
- """Doesn't need chaperone\" """
|
||||
+ """Doesn't need chaperone\""""
|
||||
|
||||
|
||||
def a8():
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
def a9():
|
||||
- """Doesn't need chaperone\\\" """
|
||||
+ """Doesn't need chaperone\\\""""
|
||||
|
||||
|
||||
def a10():
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
|
||||
def a13():
|
||||
- """Doesn't need chaperone\\\"\"\" """
|
||||
+ """Doesn't need chaperone\\\"\"\""""
|
||||
|
||||
|
||||
def a14():
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue