diff --git a/src/checkers/noqa.rs b/src/checkers/noqa.rs index 991a01ab07..f650bfbd50 100644 --- a/src/checkers/noqa.rs +++ b/src/checkers/noqa.rs @@ -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; } diff --git a/src/commands.rs b/src/commands.rs index cb9a32c46b..a7160e436b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -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, diff --git a/src/flake8_boolean_trap/plugins.rs b/src/flake8_boolean_trap/plugins.rs index 73dff14e7f..a73b4cb168 100644 --- a/src/flake8_boolean_trap/plugins.rs +++ b/src/flake8_boolean_trap/plugins.rs @@ -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(), ); } } diff --git a/src/flake8_bugbear/plugins/function_call_argument_default.rs b/src/flake8_bugbear/plugins/function_call_argument_default.rs index 80642b3c20..ac98bb8292 100644 --- a/src/flake8_bugbear/plugins/function_call_argument_default.rs +++ b/src/flake8_bugbear/plugins/function_call_argument_default.rs @@ -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), )); } diff --git a/src/flake8_builtins/checks.rs b/src/flake8_builtins/checks.rs index 647ad8dfaa..e0631d3de8 100644 --- a/src/flake8_builtins/checks.rs +++ b/src/flake8_builtins/checks.rs @@ -13,11 +13,17 @@ pub fn builtin_shadowing( node_type: ShadowingType, ) -> Option { if BUILTINS.contains(&name) { - Some(Check::new( + Some(Check::new::( 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), )) diff --git a/src/flake8_unused_arguments/types.rs b/src/flake8_unused_arguments/types.rs index 5c901704c3..0f1bb32f83 100644 --- a/src/flake8_unused_arguments/types.rs +++ b/src/flake8_unused_arguments/types.rs @@ -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(), } } diff --git a/src/pyupgrade/plugins/type_of_primitive.rs b/src/pyupgrade/plugins/type_of_primitive.rs index 8faa953b5c..ba9b4b81eb 100644 --- a/src/pyupgrade/plugins/type_of_primitive.rs +++ b/src/pyupgrade/plugins/type_of_primitive.rs @@ -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, diff --git a/src/ruff/checks.rs b/src/ruff/checks.rs index a94d6885d5..e8a013dfcf 100644 --- a/src/ruff/checks.rs +++ b/src/ruff/checks.rs @@ -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::( 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), );