mirror of https://github.com/astral-sh/ruff
structs 1/9: Manually preprocess registry.rs
This commit is contained in:
parent
eea1379a74
commit
15084dff9d
|
|
@ -2599,18 +2599,18 @@ impl CheckKind {
|
||||||
CheckKind::ExpressionsInStarAssignment => {
|
CheckKind::ExpressionsInStarAssignment => {
|
||||||
"Too many expressions in star-unpacking assignment".to_string()
|
"Too many expressions in star-unpacking assignment".to_string()
|
||||||
}
|
}
|
||||||
CheckKind::TrueFalseComparison(true, EqCmpop::Eq) => {
|
CheckKind::TrueFalseComparison(value, op) => match (value, op) {
|
||||||
"Comparison to `True` should be `cond is True`".to_string()
|
(true, EqCmpop::Eq) => "Comparison to `True` should be `cond is True`".to_string(),
|
||||||
}
|
(true, EqCmpop::NotEq) => {
|
||||||
CheckKind::TrueFalseComparison(true, EqCmpop::NotEq) => {
|
"Comparison to `True` should be `cond is not True`".to_string()
|
||||||
"Comparison to `True` should be `cond is not True`".to_string()
|
}
|
||||||
}
|
(false, EqCmpop::Eq) => {
|
||||||
CheckKind::TrueFalseComparison(false, EqCmpop::Eq) => {
|
"Comparison to `False` should be `cond is False`".to_string()
|
||||||
"Comparison to `False` should be `cond is False`".to_string()
|
}
|
||||||
}
|
(false, EqCmpop::NotEq) => {
|
||||||
CheckKind::TrueFalseComparison(false, EqCmpop::NotEq) => {
|
"Comparison to `False` should be `cond is not False`".to_string()
|
||||||
"Comparison to `False` should be `cond is not False`".to_string()
|
}
|
||||||
}
|
},
|
||||||
CheckKind::TwoStarredExpressions => "Two starred expressions in assignment".to_string(),
|
CheckKind::TwoStarredExpressions => "Two starred expressions in assignment".to_string(),
|
||||||
CheckKind::TypeComparison => "Do not compare types, use `isinstance()`".to_string(),
|
CheckKind::TypeComparison => "Do not compare types, use `isinstance()`".to_string(),
|
||||||
CheckKind::UndefinedExport(name) => {
|
CheckKind::UndefinedExport(name) => {
|
||||||
|
|
@ -3342,9 +3342,13 @@ impl CheckKind {
|
||||||
CheckKind::HardcodedBindAllInterfaces => {
|
CheckKind::HardcodedBindAllInterfaces => {
|
||||||
"Possible binding to all interfaces".to_string()
|
"Possible binding to all interfaces".to_string()
|
||||||
}
|
}
|
||||||
CheckKind::HardcodedPasswordString(string)
|
CheckKind::HardcodedPasswordString(string) => {
|
||||||
| CheckKind::HardcodedPasswordFuncArg(string)
|
format!("Possible hardcoded password: \"{}\"", string.escape_debug())
|
||||||
| CheckKind::HardcodedPasswordDefault(string) => {
|
}
|
||||||
|
CheckKind::HardcodedPasswordFuncArg(string) => {
|
||||||
|
format!("Possible hardcoded password: \"{}\"", string.escape_debug())
|
||||||
|
}
|
||||||
|
CheckKind::HardcodedPasswordDefault(string) => {
|
||||||
format!("Possible hardcoded password: \"{}\"", string.escape_debug())
|
format!("Possible hardcoded password: \"{}\"", string.escape_debug())
|
||||||
}
|
}
|
||||||
CheckKind::HardcodedTempFile(string) => {
|
CheckKind::HardcodedTempFile(string) => {
|
||||||
|
|
@ -3833,7 +3837,7 @@ impl CheckKind {
|
||||||
| CheckKind::UselessYieldFixture(..)
|
| CheckKind::UselessYieldFixture(..)
|
||||||
| CheckKind::YodaConditions(..) => true,
|
| CheckKind::YodaConditions(..) => true,
|
||||||
// Conditionally-fixable checks.
|
// Conditionally-fixable checks.
|
||||||
CheckKind::UnusedImport(_, false, _) => true,
|
CheckKind::UnusedImport(_, ignore_init, _) => !ignore_init,
|
||||||
CheckKind::BlankLineAfterSummary(num_lines) if *num_lines > 0 => true,
|
CheckKind::BlankLineAfterSummary(num_lines) if *num_lines > 0 => true,
|
||||||
// Non-fixable checks.
|
// Non-fixable checks.
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
@ -3845,9 +3849,13 @@ impl CheckKind {
|
||||||
match self {
|
match self {
|
||||||
CheckKind::AAndNotA(..) => Some("Replace with `False`".to_string()),
|
CheckKind::AAndNotA(..) => Some("Replace with `False`".to_string()),
|
||||||
CheckKind::AOrNotA(..) => Some("Replace with `True`".to_string()),
|
CheckKind::AOrNotA(..) => Some("Replace with `True`".to_string()),
|
||||||
CheckKind::AmbiguousUnicodeCharacterString(confusable, representant)
|
CheckKind::AmbiguousUnicodeCharacterString(confusable, representant) => {
|
||||||
| CheckKind::AmbiguousUnicodeCharacterDocstring(confusable, representant)
|
Some(format!("Replace '{confusable}' with '{representant}'"))
|
||||||
| CheckKind::AmbiguousUnicodeCharacterComment(confusable, representant) => {
|
}
|
||||||
|
CheckKind::AmbiguousUnicodeCharacterDocstring(confusable, representant) => {
|
||||||
|
Some(format!("Replace '{confusable}' with '{representant}'"))
|
||||||
|
}
|
||||||
|
CheckKind::AmbiguousUnicodeCharacterComment(confusable, representant) => {
|
||||||
Some(format!("Replace '{confusable}' with '{representant}'"))
|
Some(format!("Replace '{confusable}' with '{representant}'"))
|
||||||
}
|
}
|
||||||
CheckKind::AndFalse => Some("Replace with `False`".to_string()),
|
CheckKind::AndFalse => Some("Replace with `False`".to_string()),
|
||||||
|
|
@ -3869,8 +3877,10 @@ impl CheckKind {
|
||||||
}
|
}
|
||||||
CheckKind::ConvertLoopToAll(all) => Some(format!("Replace with `{all}`")),
|
CheckKind::ConvertLoopToAll(all) => Some(format!("Replace with `{all}`")),
|
||||||
CheckKind::ConvertLoopToAny(any) => Some(format!("Replace with `{any}`")),
|
CheckKind::ConvertLoopToAny(any) => Some(format!("Replace with `{any}`")),
|
||||||
CheckKind::ConvertTypedDictFunctionalToClass(name)
|
CheckKind::ConvertTypedDictFunctionalToClass(name) => {
|
||||||
| CheckKind::ConvertNamedTupleFunctionalToClass(name) => {
|
Some(format!("Convert `{name}` to class syntax"))
|
||||||
|
}
|
||||||
|
CheckKind::ConvertNamedTupleFunctionalToClass(name) => {
|
||||||
Some(format!("Convert `{name}` to class syntax"))
|
Some(format!("Convert `{name}` to class syntax"))
|
||||||
}
|
}
|
||||||
CheckKind::DashedUnderlineAfterSection(name) => {
|
CheckKind::DashedUnderlineAfterSection(name) => {
|
||||||
|
|
@ -3991,8 +4001,11 @@ impl CheckKind {
|
||||||
}
|
}
|
||||||
CheckKind::PreferListBuiltin => Some("Replace with `list`".to_string()),
|
CheckKind::PreferListBuiltin => Some("Replace with `list`".to_string()),
|
||||||
CheckKind::PPrintFound => Some("Remove `pprint`".to_string()),
|
CheckKind::PPrintFound => Some("Remove `pprint`".to_string()),
|
||||||
CheckKind::PercentFormatExtraNamedArguments(missing)
|
CheckKind::PercentFormatExtraNamedArguments(missing) => {
|
||||||
| CheckKind::StringDotFormatExtraNamedArguments(missing) => {
|
let message = missing.join(", ");
|
||||||
|
Some(format!("Remove extra named arguments: {message}"))
|
||||||
|
}
|
||||||
|
CheckKind::StringDotFormatExtraNamedArguments(missing) => {
|
||||||
let message = missing.join(", ");
|
let message = missing.join(", ");
|
||||||
Some(format!("Remove extra named arguments: {message}"))
|
Some(format!("Remove extra named arguments: {message}"))
|
||||||
}
|
}
|
||||||
|
|
@ -4026,18 +4039,12 @@ impl CheckKind {
|
||||||
}
|
}
|
||||||
CheckKind::SetAttrWithConstant => Some("Replace `setattr` with assignment".to_string()),
|
CheckKind::SetAttrWithConstant => Some("Replace `setattr` with assignment".to_string()),
|
||||||
CheckKind::SuperCallWithParameters => Some("Remove `__super__` parameters".to_string()),
|
CheckKind::SuperCallWithParameters => Some("Remove `__super__` parameters".to_string()),
|
||||||
CheckKind::TrueFalseComparison(true, EqCmpop::Eq) => {
|
CheckKind::TrueFalseComparison(value, op) => Some(match (value, op) {
|
||||||
Some("Replace with `cond is True`".to_string())
|
(true, EqCmpop::Eq) => "Replace with `cond is True`".to_string(),
|
||||||
}
|
(true, EqCmpop::NotEq) => "Replace with `cond is not True`".to_string(),
|
||||||
CheckKind::TrueFalseComparison(true, EqCmpop::NotEq) => {
|
(false, EqCmpop::Eq) => "Replace with `cond is False`".to_string(),
|
||||||
Some("Replace with `cond is not True`".to_string())
|
(false, EqCmpop::NotEq) => "Replace with `cond is not False`".to_string(),
|
||||||
}
|
}),
|
||||||
CheckKind::TrueFalseComparison(false, EqCmpop::Eq) => {
|
|
||||||
Some("Replace with `cond is False`".to_string())
|
|
||||||
}
|
|
||||||
CheckKind::TrueFalseComparison(false, EqCmpop::NotEq) => {
|
|
||||||
Some("Replace with `cond is not False`".to_string())
|
|
||||||
}
|
|
||||||
CheckKind::TypeOfPrimitive(primitive) => Some(format!(
|
CheckKind::TypeOfPrimitive(primitive) => Some(format!(
|
||||||
"Replace `type(...)` with `{}`",
|
"Replace `type(...)` with `{}`",
|
||||||
primitive.builtin()
|
primitive.builtin()
|
||||||
|
|
@ -4099,11 +4106,15 @@ impl CheckKind {
|
||||||
}),
|
}),
|
||||||
CheckKind::UnnecessaryReturnNone => Some("Remove explicit `return None`".to_string()),
|
CheckKind::UnnecessaryReturnNone => Some("Remove explicit `return None`".to_string()),
|
||||||
CheckKind::UnsortedImports => Some("Organize imports".to_string()),
|
CheckKind::UnsortedImports => Some("Organize imports".to_string()),
|
||||||
CheckKind::UnusedImport(name, false, multiple) => {
|
CheckKind::UnusedImport(name, ignore_init, multiple) => {
|
||||||
if *multiple {
|
if !*ignore_init {
|
||||||
Some("Remove unused import".to_string())
|
Some(if *multiple {
|
||||||
|
"Remove unused import".to_string()
|
||||||
|
} else {
|
||||||
|
format!("Remove unused import: `{name}`")
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
Some(format!("Remove unused import: `{name}`"))
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckKind::UnusedLoopControlVariable(name) => {
|
CheckKind::UnusedLoopControlVariable(name) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue