diff --git a/src/registry.rs b/src/registry.rs index 2812bb2697..fdc969ba9e 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -128,7 +128,7 @@ ruff_macros::define_rule_mapping!( B904 => rules::flake8_bugbear::rules::RaiseWithoutFromInsideExcept, B905 => rules::flake8_bugbear::rules::ZipWithoutExplicitStrict, // flake8-blind-except - BLE001 => violations::BlindExcept, + BLE001 => rules::flake8_blind_except::rules::BlindExcept, // flake8-comprehensions C400 => rules::flake8_comprehensions::rules::UnnecessaryGeneratorList, C401 => rules::flake8_comprehensions::rules::UnnecessaryGeneratorSet, diff --git a/src/rules/flake8_blind_except/rules.rs b/src/rules/flake8_blind_except/rules.rs index 17097c6215..b0fc6b85fa 100644 --- a/src/rules/flake8_blind_except/rules.rs +++ b/src/rules/flake8_blind_except/rules.rs @@ -1,11 +1,25 @@ -use rustpython_ast::{Expr, ExprKind, Stmt, StmtKind}; - use crate::ast::helpers; use crate::ast::helpers::{find_keyword, is_const_true}; use crate::ast::types::Range; use crate::checkers::ast::Checker; +use crate::define_violation; use crate::registry::Diagnostic; -use crate::violations; +use crate::violation::Violation; +use ruff_macros::derive_message_formats; +use rustpython_ast::{Expr, ExprKind, Stmt, StmtKind}; + +define_violation!( + pub struct BlindExcept { + pub name: String, + } +); +impl Violation for BlindExcept { + #[derive_message_formats] + fn message(&self) -> String { + let BlindExcept { name } = self; + format!("Do not catch blind exception: `{name}`") + } +} /// BLE001 pub fn blind_except( @@ -67,7 +81,7 @@ pub fn blind_except( } checker.diagnostics.push(Diagnostic::new( - violations::BlindExcept { + BlindExcept { name: id.to_string(), }, Range::from_located(type_), diff --git a/src/violations.rs b/src/violations.rs index 6c1630d200..180c5377ac 100644 --- a/src/violations.rs +++ b/src/violations.rs @@ -943,21 +943,6 @@ impl Violation for GlobalVariableNotAssigned { } } -// flake8-blind-except - -define_violation!( - pub struct BlindExcept { - pub name: String, - } -); -impl Violation for BlindExcept { - #[derive_message_formats] - fn message(&self) -> String { - let BlindExcept { name } = self; - format!("Do not catch blind exception: `{name}`") - } -} - // flake8-debugger define_violation!(