mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +00:00
Replace format!
without parameters with .to_string()
(#14090)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
6dabf045c3
commit
a7a78f939c
69 changed files with 126 additions and 135 deletions
|
@ -41,7 +41,7 @@ impl Violation for CommentedOutCode {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Remove commented-out code"))
|
||||
Some("Remove commented-out code".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,12 +229,11 @@ impl Violation for MissingReturnTypeUndocumentedPublicFunction {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let Self { annotation, .. } = self;
|
||||
if let Some(annotation) = annotation {
|
||||
Some(format!("Add return type annotation: `{annotation}`"))
|
||||
} else {
|
||||
Some(format!("Add return type annotation"))
|
||||
}
|
||||
let title = match &self.annotation {
|
||||
Some(annotation) => format!("Add return type annotation: `{annotation}`"),
|
||||
None => "Add return type annotation".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,12 +272,11 @@ impl Violation for MissingReturnTypePrivateFunction {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let Self { annotation, .. } = self;
|
||||
if let Some(annotation) = annotation {
|
||||
Some(format!("Add return type annotation: `{annotation}`"))
|
||||
} else {
|
||||
Some(format!("Add return type annotation"))
|
||||
}
|
||||
let title = match &self.annotation {
|
||||
Some(annotation) => format!("Add return type annotation: `{annotation}`"),
|
||||
None => "Add return type annotation".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,12 +328,11 @@ impl Violation for MissingReturnTypeSpecialMethod {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let Self { annotation, .. } = self;
|
||||
if let Some(annotation) = annotation {
|
||||
Some(format!("Add return type annotation: `{annotation}`"))
|
||||
} else {
|
||||
Some(format!("Add return type annotation"))
|
||||
}
|
||||
let title = match &self.annotation {
|
||||
Some(annotation) => format!("Add return type annotation: `{annotation}`"),
|
||||
None => "Add return type annotation".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,12 +375,11 @@ impl Violation for MissingReturnTypeStaticMethod {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let Self { annotation, .. } = self;
|
||||
if let Some(annotation) = annotation {
|
||||
Some(format!("Add return type annotation: `{annotation}`"))
|
||||
} else {
|
||||
Some(format!("Add return type annotation"))
|
||||
}
|
||||
let title = match &self.annotation {
|
||||
Some(annotation) => format!("Add return type annotation: `{annotation}`"),
|
||||
None => "Add return type annotation".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,12 +422,11 @@ impl Violation for MissingReturnTypeClassMethod {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let Self { annotation, .. } = self;
|
||||
if let Some(annotation) = annotation {
|
||||
Some(format!("Add return type annotation: `{annotation}`"))
|
||||
} else {
|
||||
Some(format!("Add return type annotation"))
|
||||
}
|
||||
let title = match &self.annotation {
|
||||
Some(annotation) => format!("Add return type annotation: `{annotation}`"),
|
||||
None => "Add return type annotation".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Violation for TrioSyncCall {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Add `await`"))
|
||||
Some("Add `await`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Violation for DuplicateValue {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Remove duplicate item"))
|
||||
Some("Remove duplicate item".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Violation for MutableArgumentDefault {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `None`; initialize within function"))
|
||||
Some("Replace with `None`; initialize within function".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Violation for UnreliableCallableCheck {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `callable()`"))
|
||||
Some("Replace with `callable()`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,12 @@ impl Violation for UnnecessaryDictComprehensionForIterable {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
if self.is_value_none_literal {
|
||||
Some(format!("Replace with `dict.fromkeys(iterable, value)`)"))
|
||||
let title = if self.is_value_none_literal {
|
||||
"Replace with `dict.fromkeys(iterable, value)`)"
|
||||
} else {
|
||||
Some(format!("Replace with `dict.fromkeys(iterable)`)"))
|
||||
}
|
||||
"Replace with `dict.fromkeys(iterable)`)"
|
||||
};
|
||||
Some(title.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ impl AlwaysFixableViolation for ShebangLeadingWhitespace {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove whitespace before shebang")
|
||||
"Remove whitespace before shebang".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ impl AlwaysFixableViolation for FutureRequiredTypeAnnotation {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Add `from __future__ import annotations`")
|
||||
"Add `from __future__ import annotations`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Violation for DirectLoggerInstantiation {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `logging.getLogger()`"))
|
||||
Some("Replace with `logging.getLogger()`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ impl Violation for InvalidGetLoggerArgument {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `__name__`"))
|
||||
Some("Replace with `__name__`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ impl Violation for UndocumentedWarn {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace `logging.WARN` with `logging.WARNING`"))
|
||||
Some("Replace `logging.WARN` with `logging.WARNING`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ impl Violation for UnnecessaryDictKwargs {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Remove unnecessary kwargs"))
|
||||
Some("Remove unnecessary kwargs".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,19 +61,18 @@ pub struct UnnecessaryPlaceholder {
|
|||
impl AlwaysFixableViolation for UnnecessaryPlaceholder {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let Self { kind } = self;
|
||||
match kind {
|
||||
match &self.kind {
|
||||
Placeholder::Pass => format!("Unnecessary `pass` statement"),
|
||||
Placeholder::Ellipsis => format!("Unnecessary `...` literal"),
|
||||
}
|
||||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
let Self { kind } = self;
|
||||
match kind {
|
||||
Placeholder::Pass => format!("Remove unnecessary `pass`"),
|
||||
Placeholder::Ellipsis => format!("Remove unnecessary `...`"),
|
||||
}
|
||||
let title = match &self.kind {
|
||||
Placeholder::Pass => "Remove unnecessary `pass`",
|
||||
Placeholder::Ellipsis => "Remove unnecessary `...`",
|
||||
};
|
||||
title.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ impl AlwaysFixableViolation for UnnecessaryRangeStart {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove `start` argument")
|
||||
"Remove `start` argument".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Violation for UnnecessarySpread {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Remove unnecessary dict"))
|
||||
Some("Remove unnecessary dict".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ impl AlwaysFixableViolation for AnyEqNeAnnotation {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with `object`")
|
||||
"Replace with `object`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Violation for CollectionsNamedTuple {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `typing.NamedTuple`"))
|
||||
Some("Replace with `typing.NamedTuple`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl AlwaysFixableViolation for NonEmptyStubBody {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace function body with `...`")
|
||||
"Replace function body with `...`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ impl AlwaysFixableViolation for PassInClassBody {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove unnecessary `pass`")
|
||||
"Remove unnecessary `pass`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ impl AlwaysFixableViolation for PassStatementStubBody {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace `pass` with `...`")
|
||||
"Replace `pass` with `...`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ impl Violation for UnaliasedCollectionsAbcSetImport {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Alias `Set` to `AbstractSet`"))
|
||||
Some("Alias `Set` to `AbstractSet`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ impl Violation for UnnecessaryTypeUnion {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Combine multiple `type` members"))
|
||||
Some("Combine multiple `type` members".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ impl AlwaysFixableViolation for UnnecessaryParenOnRaiseException {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove unnecessary parentheses")
|
||||
"Remove unnecessary parentheses".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ impl Violation for IfExprWithTrueFalse {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let IfExprWithTrueFalse { is_compare } = self;
|
||||
if *is_compare {
|
||||
Some(format!("Remove unnecessary `True if ... else False`"))
|
||||
let title = if self.is_compare {
|
||||
"Remove unnecessary `True if ... else False`"
|
||||
} else {
|
||||
Some(format!("Replace with `bool(...)"))
|
||||
}
|
||||
"Replace with `bool(...)"
|
||||
};
|
||||
Some(title.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ impl AlwaysFixableViolation for InDictKeys {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
let InDictKeys { operator: _ } = self;
|
||||
format!("Remove `.keys()`")
|
||||
"Remove `.keys()`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ impl Violation for NeedlessBool {
|
|||
if let Some(condition) = condition.as_ref().and_then(SourceCodeSnippet::full_display) {
|
||||
Some(format!("Replace with `return {condition}`"))
|
||||
} else {
|
||||
Some(format!("Inline condition"))
|
||||
Some("Inline condition".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ impl AlwaysFixableViolation for EmptyTypeCheckingBlock {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Delete empty type-checking block")
|
||||
"Delete empty type-checking block".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ impl AlwaysFixableViolation for StaticJoinToFString {
|
|||
if let Some(expression) = expression.full_display() {
|
||||
format!("Replace with `{expression}`")
|
||||
} else {
|
||||
format!("Replace with f-string")
|
||||
"Replace with f-string".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ impl AlwaysFixableViolation for UnnecessaryListCast {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove `list()` cast")
|
||||
"Remove `list()` cast".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ impl AlwaysFixableViolation for InvalidEscapeSequence {
|
|||
|
||||
fn fix_title(&self) -> String {
|
||||
match self.fix_title {
|
||||
FixTitle::AddBackslash => format!("Add backslash to escape sequence"),
|
||||
FixTitle::UseRawStringLiteral => format!("Use a raw string literal"),
|
||||
FixTitle::AddBackslash => "Add backslash to escape sequence".to_string(),
|
||||
FixTitle::UseRawStringLiteral => "Use a raw string literal".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ impl AlwaysFixableViolation for MissingWhitespace {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Add missing whitespace")
|
||||
"Add missing whitespace".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ impl AlwaysFixableViolation for MissingWhitespaceAfterKeyword {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Added missing whitespace after keyword")
|
||||
"Added missing whitespace after keyword".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl AlwaysFixableViolation for MissingWhitespaceAroundOperator {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Add missing whitespace")
|
||||
"Add missing whitespace".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ impl AlwaysFixableViolation for TabBeforeOperator {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with single space")
|
||||
"Replace with single space".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ impl AlwaysFixableViolation for MultipleSpacesAfterKeyword {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with single space")
|
||||
"Replace with single space".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ impl AlwaysFixableViolation for UnexpectedSpacesAroundKeywordParameterEquals {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove whitespace")
|
||||
"Remove whitespace".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ impl AlwaysFixableViolation for TooFewSpacesBeforeInlineComment {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Insert spaces")
|
||||
"Insert spaces".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Violation for MultipleImportsOnOneLine {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Split imports"))
|
||||
Some("Split imports".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ impl Violation for DocstringMissingReturns {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Add a \"Returns\" section to the docstring"))
|
||||
Some("Add a \"Returns\" section to the docstring".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ impl Violation for TripleSingleQuotes {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let TripleSingleQuotes { expected_quote } = self;
|
||||
Some(match expected_quote {
|
||||
Quote::Double => format!("Convert to triple double quotes"),
|
||||
Quote::Single => format!("Convert to triple single quotes"),
|
||||
})
|
||||
let title = match self.expected_quote {
|
||||
Quote::Double => "Convert to triple double quotes",
|
||||
Quote::Single => "Convert to triple single quotes",
|
||||
};
|
||||
Some(title.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,12 +72,11 @@ impl Violation for MultiValueRepeatedKeyLiteral {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let MultiValueRepeatedKeyLiteral { name, .. } = self;
|
||||
if let Some(name) = name.full_display() {
|
||||
Some(format!("Remove repeated key literal `{name}`"))
|
||||
} else {
|
||||
Some(format!("Remove repeated key literal"))
|
||||
}
|
||||
let title = match self.name.full_display() {
|
||||
Some(name) => format!("Remove repeated key literal `{name}`"),
|
||||
None => "Remove repeated key literal".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,12 +128,11 @@ impl Violation for MultiValueRepeatedKeyVariable {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let MultiValueRepeatedKeyVariable { name } = self;
|
||||
if let Some(name) = name.full_display() {
|
||||
Some(format!("Remove repeated key `{name}`"))
|
||||
} else {
|
||||
Some(format!("Remove repeated key"))
|
||||
}
|
||||
let title = match self.name.full_display() {
|
||||
Some(name) => format!("Remove repeated key `{name}`"),
|
||||
None => "Remove repeated key".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,6 @@ impl Violation for DeprecatedLogWarn {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `warning`"))
|
||||
Some("Replace with `warning`".to_string())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ impl AlwaysFixableViolation for DictIterMissingItems {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Add a call to `.items()`")
|
||||
"Add a call to `.items()`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ impl Violation for EmptyComment {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Delete the empty comment"))
|
||||
Some("Delete the empty comment".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ impl AlwaysFixableViolation for IterationOverSet {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Convert to `tuple`")
|
||||
"Convert to `tuple`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ impl AlwaysFixableViolation for LiteralMembership {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Convert to `set`")
|
||||
"Convert to `set`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ impl AlwaysFixableViolation for NoClassmethodDecorator {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Add @classmethod decorator")
|
||||
"Add @classmethod decorator".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl AlwaysFixableViolation for RepeatedEqualityComparison {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Merge multiple comparisons")
|
||||
"Merge multiple comparisons".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ impl AlwaysFixableViolation for RepeatedIsinstanceCalls {
|
|||
if let Some(expression) = expression.full_display() {
|
||||
format!("Replace with `{expression}`")
|
||||
} else {
|
||||
format!("Replace with merged `isinstance` call")
|
||||
"Replace with merged `isinstance` call".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ impl AlwaysFixableViolation for UnnecessaryDictIndexLookup {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Use existing variable")
|
||||
"Use existing variable".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ impl AlwaysFixableViolation for UnnecessaryListIndexLookup {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Use the loop variable directly")
|
||||
"Use the loop variable directly".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ impl AlwaysFixableViolation for UnspecifiedEncoding {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Add explicit `encoding` argument")
|
||||
"Add explicit `encoding` argument".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Violation for UselessExceptionStatement {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Add `raise` keyword"))
|
||||
Some("Add `raise` keyword".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl AlwaysFixableViolation for UselessReturn {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove useless `return` statement")
|
||||
"Remove useless `return` statement".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl AlwaysFixableViolation for UnnecessaryDefaultTypeArgs {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove default type arguments")
|
||||
"Remove default type arguments".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ impl AlwaysFixableViolation for BitCount {
|
|||
if let Some(replacement) = replacement.full_display() {
|
||||
format!("Replace with `{replacement}`")
|
||||
} else {
|
||||
format!("Replace with `.bit_count()`")
|
||||
"Replace with `.bit_count()`".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ impl Violation for FStringNumberFormat {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let FStringNumberFormat { replacement, .. } = self;
|
||||
if let Some(display) = replacement
|
||||
if let Some(display) = self
|
||||
.replacement
|
||||
.as_ref()
|
||||
.and_then(SourceCodeSnippet::full_display)
|
||||
{
|
||||
Some(format!("Replace with `{display}`"))
|
||||
} else {
|
||||
Some(format!("Replace with f-string"))
|
||||
Some("Replace with f-string".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Violation for IfExpInsteadOfOrOperator {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `or` operator"))
|
||||
Some("Replace with `or` operator".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl AlwaysFixableViolation for IntOnSlicedStr {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with `base=0`")
|
||||
"Replace with `base=0`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ impl AlwaysFixableViolation for MetaClassABCMeta {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with `abc.ABC`")
|
||||
"Replace with `abc.ABC`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ impl Violation for ReimplementedStarmap {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `itertools.starmap`"))
|
||||
Some("Replace with `itertools.starmap`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,11 @@ impl Violation for CollectionLiteralConcatenation {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
let CollectionLiteralConcatenation { expression } = self;
|
||||
if let Some(expression) = expression.full_display() {
|
||||
Some(format!("Replace with `{expression}`"))
|
||||
} else {
|
||||
Some(format!("Replace with iterable unpacking"))
|
||||
}
|
||||
let title = match self.expression.full_display() {
|
||||
Some(expression) => format!("Replace with `{expression}`"),
|
||||
None => "Replace with iterable unpacking".to_string(),
|
||||
};
|
||||
Some(title)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ impl AlwaysFixableViolation for InvalidFormatterSuppressionComment {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove this comment")
|
||||
"Remove this comment".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ impl Violation for PostInitDefault {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Use `dataclasses.InitVar` instead"))
|
||||
Some("Use `dataclasses.InitVar` instead".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ impl AlwaysFixableViolation for QuadraticListSummation {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with `functools.reduce`")
|
||||
"Replace with `functools.reduce`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl AlwaysFixableViolation for UnnecessaryKeyCheck {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Replace with `dict.get`")
|
||||
"Replace with `dict.get`".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl Violation for ErrorInsteadOfException {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some(format!("Replace with `exception`"))
|
||||
Some("Replace with `exception`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl AlwaysFixableViolation for VerboseRaise {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
format!("Remove exception name")
|
||||
"Remove exception name".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue