mirror of https://github.com/astral-sh/ruff
Update documentation to list double-quote preference first (#5507)
Closes https://github.com/astral-sh/ruff/issues/5496.
This commit is contained in:
parent
521e6de2c8
commit
75da72bd7f
|
|
@ -42,16 +42,16 @@ impl AlwaysAutofixableViolation for BadQuotesInlineString {
|
|||
fn message(&self) -> String {
|
||||
let BadQuotesInlineString { quote } = self;
|
||||
match quote {
|
||||
Quote::Single => format!("Double quotes found but single quotes preferred"),
|
||||
Quote::Double => format!("Single quotes found but double quotes preferred"),
|
||||
Quote::Single => format!("Double quotes found but single quotes preferred"),
|
||||
}
|
||||
}
|
||||
|
||||
fn autofix_title(&self) -> String {
|
||||
let BadQuotesInlineString { quote } = self;
|
||||
match quote {
|
||||
Quote::Single => "Replace double quotes with single quotes".to_string(),
|
||||
Quote::Double => "Replace single quotes with double quotes".to_string(),
|
||||
Quote::Single => "Replace double quotes with single quotes".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,16 +91,16 @@ impl AlwaysAutofixableViolation for BadQuotesMultilineString {
|
|||
fn message(&self) -> String {
|
||||
let BadQuotesMultilineString { quote } = self;
|
||||
match quote {
|
||||
Quote::Single => format!("Double quote multiline found but single quotes preferred"),
|
||||
Quote::Double => format!("Single quote multiline found but double quotes preferred"),
|
||||
Quote::Single => format!("Double quote multiline found but single quotes preferred"),
|
||||
}
|
||||
}
|
||||
|
||||
fn autofix_title(&self) -> String {
|
||||
let BadQuotesMultilineString { quote } = self;
|
||||
match quote {
|
||||
Quote::Single => "Replace double multiline quotes with single quotes".to_string(),
|
||||
Quote::Double => "Replace single multiline quotes with double quotes".to_string(),
|
||||
Quote::Single => "Replace double multiline quotes with single quotes".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -139,16 +139,16 @@ impl AlwaysAutofixableViolation for BadQuotesDocstring {
|
|||
fn message(&self) -> String {
|
||||
let BadQuotesDocstring { quote } = self;
|
||||
match quote {
|
||||
Quote::Single => format!("Double quote docstring found but single quotes preferred"),
|
||||
Quote::Double => format!("Single quote docstring found but double quotes preferred"),
|
||||
Quote::Single => format!("Double quote docstring found but single quotes preferred"),
|
||||
}
|
||||
}
|
||||
|
||||
fn autofix_title(&self) -> String {
|
||||
let BadQuotesDocstring { quote } = self;
|
||||
match quote {
|
||||
Quote::Single => "Replace double quotes docstring with single quotes".to_string(),
|
||||
Quote::Double => "Replace single quotes docstring with double quotes".to_string(),
|
||||
Quote::Single => "Replace double quotes docstring with single quotes".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -186,8 +186,8 @@ impl AlwaysAutofixableViolation for AvoidableEscapedQuote {
|
|||
|
||||
const fn good_single(quote: Quote) -> char {
|
||||
match quote {
|
||||
Quote::Single => '\'',
|
||||
Quote::Double => '"',
|
||||
Quote::Single => '\'',
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,22 +200,22 @@ const fn bad_single(quote: Quote) -> char {
|
|||
|
||||
const fn good_multiline(quote: Quote) -> &'static str {
|
||||
match quote {
|
||||
Quote::Single => "'''",
|
||||
Quote::Double => "\"\"\"",
|
||||
Quote::Single => "'''",
|
||||
}
|
||||
}
|
||||
|
||||
const fn good_multiline_ending(quote: Quote) -> &'static str {
|
||||
match quote {
|
||||
Quote::Single => "'\"\"\"",
|
||||
Quote::Double => "\"'''",
|
||||
Quote::Single => "'\"\"\"",
|
||||
}
|
||||
}
|
||||
|
||||
const fn good_docstring(quote: Quote) -> &'static str {
|
||||
match quote {
|
||||
Quote::Single => "'",
|
||||
Quote::Double => "\"",
|
||||
Quote::Single => "'",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ use ruff_macros::{CacheKey, CombineOptions, ConfigurationOptions};
|
|||
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum Quote {
|
||||
/// Use single quotes.
|
||||
Single,
|
||||
/// Use double quotes.
|
||||
Double,
|
||||
/// Use single quotes.
|
||||
Single,
|
||||
}
|
||||
|
||||
impl Default for Quote {
|
||||
|
|
|
|||
|
|
@ -1585,19 +1585,19 @@
|
|||
},
|
||||
"Quote": {
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "Use single quotes.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"single"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Use double quotes.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"double"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Use single quotes.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"single"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue