structs 7/9: Manually fix errors introduced in the previous commit

This commit is contained in:
Martin Fischer
2023-01-06 23:09:40 +01:00
committed by Charlie Marsh
parent 43db446dfa
commit 6208eb7bbf
8 changed files with 28 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ pub fn check_noqa(
// Remove any ignored checks.
for (index, check) in checks.iter().enumerate() {
if check.kind == violations::BlanketNOQA {
if matches!(check.kind, CheckKind::BlanketNOQA(..)) {
continue;
}

View File

@@ -119,7 +119,7 @@ pub fn run(
let settings = resolver.resolve(path, pyproject_strategy);
if settings.enabled.contains(&CheckCode::E902) {
Diagnostics::new(vec![Message {
kind: violations::IOError(message),
kind: violations::IOError(message).into(),
location: Location::default(),
end_location: Location::default(),
fix: None,

View File

@@ -91,7 +91,7 @@ pub fn check_boolean_default_value_in_function_definition(
add_if_boolean(
checker,
arg,
violations::BooleanDefaultValueInFunctionDefinition,
violations::BooleanDefaultValueInFunctionDefinition.into(),
);
}
}
@@ -108,7 +108,7 @@ pub fn check_boolean_positional_value_in_function_call(
add_if_boolean(
checker,
arg,
violations::BooleanPositionalValueInFunctionCall,
violations::BooleanPositionalValueInFunctionCall.into(),
);
}
}

View File

@@ -59,7 +59,7 @@ where
&& !is_nan_or_infinity(func, args)
{
self.checks.push((
violations::FunctionCallArgumentDefault(compose_call_path(expr)),
violations::FunctionCallArgumentDefault(compose_call_path(expr)).into(),
Range::from_located(expr),
));
}

View File

@@ -13,11 +13,17 @@ pub fn builtin_shadowing<T>(
node_type: ShadowingType,
) -> Option<Check> {
if BUILTINS.contains(&name) {
Some(Check::new(
Some(Check::new::<CheckKind>(
match node_type {
ShadowingType::Variable => violations::BuiltinVariableShadowing(name.to_string()),
ShadowingType::Argument => violations::BuiltinArgumentShadowing(name.to_string()),
ShadowingType::Attribute => violations::BuiltinAttributeShadowing(name.to_string()),
ShadowingType::Variable => {
violations::BuiltinVariableShadowing(name.to_string()).into()
}
ShadowingType::Argument => {
violations::BuiltinArgumentShadowing(name.to_string()).into()
}
ShadowingType::Attribute => {
violations::BuiltinAttributeShadowing(name.to_string()).into()
}
},
Range::from_located(located),
))

View File

@@ -13,11 +13,11 @@ pub enum Argumentable {
impl Argumentable {
pub fn check_for(&self, name: String) -> CheckKind {
match self {
Argumentable::Function => violations::UnusedFunctionArgument(name),
Argumentable::Method => violations::UnusedMethodArgument(name),
Argumentable::ClassMethod => violations::UnusedClassMethodArgument(name),
Argumentable::StaticMethod => violations::UnusedStaticMethodArgument(name),
Argumentable::Lambda => violations::UnusedLambdaArgument(name),
Argumentable::Function => violations::UnusedFunctionArgument(name).into(),
Argumentable::Method => violations::UnusedMethodArgument(name).into(),
Argumentable::ClassMethod => violations::UnusedClassMethodArgument(name).into(),
Argumentable::StaticMethod => violations::UnusedStaticMethodArgument(name).into(),
Argumentable::Lambda => violations::UnusedLambdaArgument(name).into(),
}
}

View File

@@ -13,7 +13,7 @@ pub fn type_of_primitive(checker: &mut Checker, expr: &Expr, func: &Expr, args:
return;
};
if checker.patch(check.kind.code()) {
if let violations::TypeOfPrimitive(primitive) = &check.kind {
if let CheckKind::TypeOfPrimitive(violations::TypeOfPrimitive(primitive)) = &check.kind {
check.amend(Fix::replacement(
primitive.builtin(),
expr.location,

View File

@@ -1630,20 +1630,23 @@ pub fn ambiguous_unicode_character(
};
let location = Location::new(start.row() + row_offset, col);
let end_location = Location::new(location.row(), location.column() + 1);
let mut check = Check::new(
let mut check = Check::new::<CheckKind>(
match context {
Context::String => violations::AmbiguousUnicodeCharacterString(
current_char,
representant,
),
)
.into(),
Context::Docstring => violations::AmbiguousUnicodeCharacterDocstring(
current_char,
representant,
),
)
.into(),
Context::Comment => violations::AmbiguousUnicodeCharacterComment(
current_char,
representant,
),
)
.into(),
},
Range::new(location, end_location),
);