Skip to content

Commit

Permalink
Update documentation to list double-quote preference first (#5507)
Browse files Browse the repository at this point in the history
Closes #5496.
  • Loading branch information
charliermarsh committed Jul 4, 2023
1 parent 521e6de commit 75da72b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions crates/ruff/src/rules/flake8_quotes/rules/from_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -186,8 +186,8 @@ impl AlwaysAutofixableViolation for AvoidableEscapedQuote {

const fn good_single(quote: Quote) -> char {
match quote {
Quote::Single => '\'',
Quote::Double => '"',
Quote::Single => '\'',
}
}

Expand All @@ -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 => "'",
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/ruff/src/rules/flake8_quotes/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions ruff.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 75da72b

Please sign in to comment.