From b74fd1fe13029388dc5b23c8e3c66ea548f32d75 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Fri, 18 Nov 2022 19:30:36 +0100 Subject: [PATCH] Change error code of flake8-blind-except (#808) --- README.md | 8 +++---- flake8_to_ruff/src/plugin.rs | 4 ++-- resources/test/fixtures/{B902.py => BLE.py} | 0 src/check_ast.rs | 2 +- src/checks.rs | 8 +++---- src/checks_gen.rs | 22 ++++++++++--------- src/linter.rs | 2 +- ...> ruff__linter__tests__BLE001_BLE.py.snap} | 0 8 files changed, 24 insertions(+), 22 deletions(-) rename resources/test/fixtures/{B902.py => BLE.py} (100%) rename src/snapshots/{ruff__linter__tests__B902_B902.py.snap => ruff__linter__tests__BLE001_BLE.py.snap} (100%) diff --git a/README.md b/README.md index eb301c5ae5..bdec993c6a 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Read the [launch blog post](https://notes.crmarsh.com/python-tooling-could-be-mu 1. [flake8-quotes (Q)](#flake8-quotes) 1. [flake8-annotations (ANN)](#flake8-annotations) 1. [flake8-2020 (YTT)](#flake8-2020) - 1. [flake8-blind-except (B90)](#flake8-blind-except) + 1. [flake8-blind-except (BLE)](#flake8-blind-except) 1. [flake8-boolean-trap (FBT)](#flake8-boolean-trap) 1. [mccabe (C90)](#mccabe) 1. [Ruff-specific rules (RUF)](#ruff-specific-rules) @@ -634,7 +634,7 @@ For more, see [flake8-blind-except](https://pypi.org/project/flake8-blind-except | Code | Name | Message | Fix | | ---- | ---- | ------- | --- | -| B902 | BlindExcept | Blind except Exception: statement | | +| BLE001 | BlindExcept | Blind except Exception: statement | | ### mccabe @@ -804,7 +804,7 @@ including: - [`flake8-bandit`](https://pypi.org/project/flake8-bandit/) (6/40) - [`flake8-bugbear`](https://pypi.org/project/flake8-bugbear/) (25/32) - [`flake8-2020`](https://pypi.org/project/flake8-2020/) -- [`flake8-blind-except`](https://pypi.org/project/flake8-blind-except/) (1/2) +- [`flake8-blind-except`](https://pypi.org/project/flake8-blind-except/) - [`flake8-boolean-trap`](https://pypi.org/project/flake8-boolean-trap/) - [`mccabe`](https://pypi.org/project/mccabe/) - [`isort`](https://pypi.org/project/isort/) @@ -835,7 +835,7 @@ Today, Ruff can be used to replace Flake8 when used with any of the following pl - [`flake8-comprehensions`](https://pypi.org/project/flake8-comprehensions/) - [`flake8-bugbear`](https://pypi.org/project/flake8-bugbear/) (26/32) - [`flake8-2020`](https://pypi.org/project/flake8-2020/) -- [`flake8-blind-except`](https://pypi.org/project/flake8-blind-except/) (1/2) +- [`flake8-blind-except`](https://pypi.org/project/flake8-blind-except/) - [`flake8-boolean-trap`](https://pypi.org/project/flake8-boolean-trap/) - [`mccabe`](https://pypi.org/project/mccabe/) diff --git a/flake8_to_ruff/src/plugin.rs b/flake8_to_ruff/src/plugin.rs index 6e5111dcbf..4d96524fd4 100644 --- a/flake8_to_ruff/src/plugin.rs +++ b/flake8_to_ruff/src/plugin.rs @@ -56,7 +56,7 @@ impl Plugin { Plugin::Flake8Print => CheckCodePrefix::T, Plugin::Flake8Quotes => CheckCodePrefix::Q, Plugin::Flake8Annotations => CheckCodePrefix::ANN, - Plugin::Flake8BlindExcept => CheckCodePrefix::B90, + Plugin::Flake8BlindExcept => CheckCodePrefix::BLE, Plugin::McCabe => CheckCodePrefix::C9, Plugin::PEP8Naming => CheckCodePrefix::N, Plugin::Pyupgrade => CheckCodePrefix::U, @@ -89,7 +89,7 @@ impl Plugin { Plugin::Flake8Print => vec![CheckCodePrefix::T], Plugin::Flake8Quotes => vec![CheckCodePrefix::Q], Plugin::Flake8Annotations => vec![CheckCodePrefix::ANN], - Plugin::Flake8BlindExcept => vec![CheckCodePrefix::B90], + Plugin::Flake8BlindExcept => vec![CheckCodePrefix::BLE], Plugin::McCabe => vec![CheckCodePrefix::C9], Plugin::PEP8Naming => vec![CheckCodePrefix::N], Plugin::Pyupgrade => vec![CheckCodePrefix::U], diff --git a/resources/test/fixtures/B902.py b/resources/test/fixtures/BLE.py similarity index 100% rename from resources/test/fixtures/B902.py rename to resources/test/fixtures/BLE.py diff --git a/src/check_ast.rs b/src/check_ast.rs index 53e0021560..01baeb2e88 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -921,7 +921,7 @@ where if self.settings.enabled.contains(&CheckCode::B013) { flake8_bugbear::plugins::redundant_tuple_in_exception_handler(self, handlers); } - if self.settings.enabled.contains(&CheckCode::B902) { + if self.settings.enabled.contains(&CheckCode::BLE001) { flake8_blind_except::plugins::blind_except(self, handlers); } } diff --git a/src/checks.rs b/src/checks.rs index 4ee881ace1..3b238465fc 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -104,7 +104,7 @@ pub enum CheckCode { B026, B027, // flake8-blind-except - B902, + BLE001, // flake8-comprehensions C400, C401, @@ -757,7 +757,7 @@ impl CheckCode { CheckCode::YTT302 => CheckKind::SysVersionCmpStr10, CheckCode::YTT303 => CheckKind::SysVersionSlice1Referenced, // flake8-blind-except - CheckCode::B902 => CheckKind::BlindExcept, + CheckCode::BLE001 => CheckKind::BlindExcept, // pyupgrade CheckCode::U001 => CheckKind::UselessMetaclassType, CheckCode::U003 => CheckKind::TypeOfPrimitive(Primitive::Str), @@ -948,7 +948,7 @@ impl CheckCode { CheckCode::B025 => CheckCategory::Flake8Bugbear, CheckCode::B026 => CheckCategory::Flake8Bugbear, CheckCode::B027 => CheckCategory::Flake8Bugbear, - CheckCode::B902 => CheckCategory::Flake8BlindExcept, + CheckCode::BLE001 => CheckCategory::Flake8BlindExcept, CheckCode::C400 => CheckCategory::Flake8Comprehensions, CheckCode::C401 => CheckCategory::Flake8Comprehensions, CheckCode::C402 => CheckCategory::Flake8Comprehensions, @@ -1164,7 +1164,7 @@ impl CheckKind { CheckKind::StarArgUnpackingAfterKeywordArg => &CheckCode::B026, CheckKind::EmptyMethodWithoutAbstractDecorator(_) => &CheckCode::B027, // flake8-blind-except - CheckKind::BlindExcept => &CheckCode::B902, + CheckKind::BlindExcept => &CheckCode::BLE001, // flake8-comprehensions CheckKind::UnnecessaryGeneratorList => &CheckCode::C400, CheckKind::UnnecessaryGeneratorSet => &CheckCode::C401, diff --git a/src/checks_gen.rs b/src/checks_gen.rs index 74a6cdf3a7..64b0916378 100644 --- a/src/checks_gen.rs +++ b/src/checks_gen.rs @@ -63,9 +63,10 @@ pub enum CheckCodePrefix { B025, B026, B027, - B9, - B90, - B902, + BLE, + BLE0, + BLE00, + BLE001, C, C4, C40, @@ -409,7 +410,6 @@ impl CheckCodePrefix { CheckCode::B025, CheckCode::B026, CheckCode::B027, - CheckCode::B902, ], CheckCodePrefix::B0 => vec![ CheckCode::B002, @@ -494,9 +494,10 @@ impl CheckCodePrefix { CheckCodePrefix::B025 => vec![CheckCode::B025], CheckCodePrefix::B026 => vec![CheckCode::B026], CheckCodePrefix::B027 => vec![CheckCode::B027], - CheckCodePrefix::B9 => vec![CheckCode::B902], - CheckCodePrefix::B90 => vec![CheckCode::B902], - CheckCodePrefix::B902 => vec![CheckCode::B902], + CheckCodePrefix::BLE => vec![CheckCode::BLE001], + CheckCodePrefix::BLE0 => vec![CheckCode::BLE001], + CheckCodePrefix::BLE00 => vec![CheckCode::BLE001], + CheckCodePrefix::BLE001 => vec![CheckCode::BLE001], CheckCodePrefix::C => vec![ CheckCode::C400, CheckCode::C401, @@ -1261,9 +1262,10 @@ impl CheckCodePrefix { CheckCodePrefix::B025 => PrefixSpecificity::Explicit, CheckCodePrefix::B026 => PrefixSpecificity::Explicit, CheckCodePrefix::B027 => PrefixSpecificity::Explicit, - CheckCodePrefix::B9 => PrefixSpecificity::Hundreds, - CheckCodePrefix::B90 => PrefixSpecificity::Tens, - CheckCodePrefix::B902 => PrefixSpecificity::Explicit, + CheckCodePrefix::BLE => PrefixSpecificity::Category, + CheckCodePrefix::BLE0 => PrefixSpecificity::Hundreds, + CheckCodePrefix::BLE00 => PrefixSpecificity::Tens, + CheckCodePrefix::BLE001 => PrefixSpecificity::Explicit, CheckCodePrefix::C => PrefixSpecificity::Category, CheckCodePrefix::C4 => PrefixSpecificity::Hundreds, CheckCodePrefix::C40 => PrefixSpecificity::Tens, diff --git a/src/linter.rs b/src/linter.rs index fbca489738..f8f2e84b16 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -351,7 +351,7 @@ mod tests { #[test_case(CheckCode::B025, Path::new("B025.py"); "B025")] #[test_case(CheckCode::B026, Path::new("B026.py"); "B026")] #[test_case(CheckCode::B027, Path::new("B027.py"); "B027")] - #[test_case(CheckCode::B902, Path::new("B902.py"); "B902")] + #[test_case(CheckCode::BLE001, Path::new("BLE.py"); "BLE001")] #[test_case(CheckCode::C400, Path::new("C400.py"); "C400")] #[test_case(CheckCode::C401, Path::new("C401.py"); "C401")] #[test_case(CheckCode::C402, Path::new("C402.py"); "C402")] diff --git a/src/snapshots/ruff__linter__tests__B902_B902.py.snap b/src/snapshots/ruff__linter__tests__BLE001_BLE.py.snap similarity index 100% rename from src/snapshots/ruff__linter__tests__B902_B902.py.snap rename to src/snapshots/ruff__linter__tests__BLE001_BLE.py.snap