Summary
Description
Ruff formatter modifies the spacing in a string within a docstring when the string contains an escaped quote. Specifically, it adds an unwanted space between the escaped quote and the closing triple quotes of the docstring.
Steps to Reproduce
- Create a Python class with the following content:
class Sample:
"""Hello "World\""""
def __init__(self, name):
self.name = name
- Run
ruff format on the file
- Observe that the formatter modifies the docstring to:
class Sample:
"""Hello "World\" """
def __init__(self, name):
self.name = name
Expected Behavior
Docstring remain unchanged after formatting as its escaped already
"""Hello "World\""""
Version
ruff 0.9.10 (0dfa810 2025-03-07)
Summary
Description
Ruff formatter modifies the spacing in a string within a docstring when the string contains an escaped quote. Specifically, it adds an unwanted space between the escaped quote and the closing triple quotes of the docstring.
Steps to Reproduce
ruff formaton the fileExpected Behavior
Docstring remain unchanged after formatting as its escaped already
"""Hello "World\""""Version
ruff 0.9.10 (0dfa810 2025-03-07)