Move flake8-blind-except violation to rule module (#2479)

This commit is contained in:
Aarni Koskela 2023-02-02 19:21:25 +02:00 committed by GitHub
parent b4b8782243
commit ac41c33d1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 20 deletions

View file

@ -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,

View file

@ -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_),

View file

@ -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!(