mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-30 08:23:53 +00:00
Move flake8-blind-except violation to rule module (#2479)
This commit is contained in:
parent
b4b8782243
commit
ac41c33d1f
3 changed files with 19 additions and 20 deletions
|
@ -128,7 +128,7 @@ ruff_macros::define_rule_mapping!(
|
||||||
B904 => rules::flake8_bugbear::rules::RaiseWithoutFromInsideExcept,
|
B904 => rules::flake8_bugbear::rules::RaiseWithoutFromInsideExcept,
|
||||||
B905 => rules::flake8_bugbear::rules::ZipWithoutExplicitStrict,
|
B905 => rules::flake8_bugbear::rules::ZipWithoutExplicitStrict,
|
||||||
// flake8-blind-except
|
// flake8-blind-except
|
||||||
BLE001 => violations::BlindExcept,
|
BLE001 => rules::flake8_blind_except::rules::BlindExcept,
|
||||||
// flake8-comprehensions
|
// flake8-comprehensions
|
||||||
C400 => rules::flake8_comprehensions::rules::UnnecessaryGeneratorList,
|
C400 => rules::flake8_comprehensions::rules::UnnecessaryGeneratorList,
|
||||||
C401 => rules::flake8_comprehensions::rules::UnnecessaryGeneratorSet,
|
C401 => rules::flake8_comprehensions::rules::UnnecessaryGeneratorSet,
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
use rustpython_ast::{Expr, ExprKind, Stmt, StmtKind};
|
|
||||||
|
|
||||||
use crate::ast::helpers;
|
use crate::ast::helpers;
|
||||||
use crate::ast::helpers::{find_keyword, is_const_true};
|
use crate::ast::helpers::{find_keyword, is_const_true};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
use crate::define_violation;
|
||||||
use crate::registry::Diagnostic;
|
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
|
/// BLE001
|
||||||
pub fn blind_except(
|
pub fn blind_except(
|
||||||
|
@ -67,7 +81,7 @@ pub fn blind_except(
|
||||||
}
|
}
|
||||||
|
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::BlindExcept {
|
BlindExcept {
|
||||||
name: id.to_string(),
|
name: id.to_string(),
|
||||||
},
|
},
|
||||||
Range::from_located(type_),
|
Range::from_located(type_),
|
||||||
|
|
|
@ -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
|
// flake8-debugger
|
||||||
|
|
||||||
define_violation!(
|
define_violation!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue