mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Stabilize quote-style preserve
(#9922)
This commit is contained in:
parent
6dc1b21917
commit
4946a1876f
7 changed files with 37 additions and 33 deletions
|
@ -50,11 +50,13 @@ impl Format<PyFormatContext<'_>> for FormatStringLiteral<'_> {
|
|||
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
let locator = f.context().locator();
|
||||
|
||||
let quote_style = if self.layout.is_docstring() {
|
||||
// Per PEP 8 and PEP 257, always prefer double quotes for docstrings
|
||||
let quote_style = f.options().quote_style();
|
||||
let quote_style = if self.layout.is_docstring() && !quote_style.is_preserve() {
|
||||
// Per PEP 8 and PEP 257, always prefer double quotes for docstrings,
|
||||
// except when using quote-style=preserve
|
||||
QuoteStyle::Double
|
||||
} else {
|
||||
f.options().quote_style()
|
||||
quote_style
|
||||
};
|
||||
|
||||
let normalized = StringPart::from_source(self.value.range(), &locator).normalize(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue