Skip to content

Commit 75da72b

Browse files
Update documentation to list double-quote preference first (#5507)
Closes #5496.
1 parent 521e6de commit 75da72b

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

crates/ruff/src/rules/flake8_quotes/rules/from_tokens.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ impl AlwaysAutofixableViolation for BadQuotesInlineString {
4242
fn message(&self) -> String {
4343
let BadQuotesInlineString { quote } = self;
4444
match quote {
45-
Quote::Single => format!("Double quotes found but single quotes preferred"),
4645
Quote::Double => format!("Single quotes found but double quotes preferred"),
46+
Quote::Single => format!("Double quotes found but single quotes preferred"),
4747
}
4848
}
4949

5050
fn autofix_title(&self) -> String {
5151
let BadQuotesInlineString { quote } = self;
5252
match quote {
53-
Quote::Single => "Replace double quotes with single quotes".to_string(),
5453
Quote::Double => "Replace single quotes with double quotes".to_string(),
54+
Quote::Single => "Replace double quotes with single quotes".to_string(),
5555
}
5656
}
5757
}
@@ -91,16 +91,16 @@ impl AlwaysAutofixableViolation for BadQuotesMultilineString {
9191
fn message(&self) -> String {
9292
let BadQuotesMultilineString { quote } = self;
9393
match quote {
94-
Quote::Single => format!("Double quote multiline found but single quotes preferred"),
9594
Quote::Double => format!("Single quote multiline found but double quotes preferred"),
95+
Quote::Single => format!("Double quote multiline found but single quotes preferred"),
9696
}
9797
}
9898

9999
fn autofix_title(&self) -> String {
100100
let BadQuotesMultilineString { quote } = self;
101101
match quote {
102-
Quote::Single => "Replace double multiline quotes with single quotes".to_string(),
103102
Quote::Double => "Replace single multiline quotes with double quotes".to_string(),
103+
Quote::Single => "Replace double multiline quotes with single quotes".to_string(),
104104
}
105105
}
106106
}
@@ -139,16 +139,16 @@ impl AlwaysAutofixableViolation for BadQuotesDocstring {
139139
fn message(&self) -> String {
140140
let BadQuotesDocstring { quote } = self;
141141
match quote {
142-
Quote::Single => format!("Double quote docstring found but single quotes preferred"),
143142
Quote::Double => format!("Single quote docstring found but double quotes preferred"),
143+
Quote::Single => format!("Double quote docstring found but single quotes preferred"),
144144
}
145145
}
146146

147147
fn autofix_title(&self) -> String {
148148
let BadQuotesDocstring { quote } = self;
149149
match quote {
150-
Quote::Single => "Replace double quotes docstring with single quotes".to_string(),
151150
Quote::Double => "Replace single quotes docstring with double quotes".to_string(),
151+
Quote::Single => "Replace double quotes docstring with single quotes".to_string(),
152152
}
153153
}
154154
}
@@ -186,8 +186,8 @@ impl AlwaysAutofixableViolation for AvoidableEscapedQuote {
186186

187187
const fn good_single(quote: Quote) -> char {
188188
match quote {
189-
Quote::Single => '\'',
190189
Quote::Double => '"',
190+
Quote::Single => '\'',
191191
}
192192
}
193193

@@ -200,22 +200,22 @@ const fn bad_single(quote: Quote) -> char {
200200

201201
const fn good_multiline(quote: Quote) -> &'static str {
202202
match quote {
203-
Quote::Single => "'''",
204203
Quote::Double => "\"\"\"",
204+
Quote::Single => "'''",
205205
}
206206
}
207207

208208
const fn good_multiline_ending(quote: Quote) -> &'static str {
209209
match quote {
210-
Quote::Single => "'\"\"\"",
211210
Quote::Double => "\"'''",
211+
Quote::Single => "'\"\"\"",
212212
}
213213
}
214214

215215
const fn good_docstring(quote: Quote) -> &'static str {
216216
match quote {
217-
Quote::Single => "'",
218217
Quote::Double => "\"",
218+
Quote::Single => "'",
219219
}
220220
}
221221

crates/ruff/src/rules/flake8_quotes/settings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use ruff_macros::{CacheKey, CombineOptions, ConfigurationOptions};
88
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
99
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
1010
pub enum Quote {
11-
/// Use single quotes.
12-
Single,
1311
/// Use double quotes.
1412
Double,
13+
/// Use single quotes.
14+
Single,
1515
}
1616

1717
impl Default for Quote {

ruff.schema.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)