From b51a080a4486e97a145630cf802220cbbd073514 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 9 Oct 2022 21:58:22 -0400 Subject: [PATCH] Rename SPR001 to U008 (#379) --- README.md | 2 +- .../test/fixtures/{SPR001.py => U008.py} | 0 src/check_ast.rs | 2 +- src/checks.rs | 19 ++--- src/linter.rs | 6 +- src/snapshots/ruff__linter__tests__u008.snap | 85 +++++++++++++++++++ 6 files changed, 97 insertions(+), 17 deletions(-) rename resources/test/fixtures/{SPR001.py => U008.py} (100%) create mode 100644 src/snapshots/ruff__linter__tests__u008.snap diff --git a/README.md b/README.md index 12d4a5fe26..002e1269cc 100644 --- a/README.md +++ b/README.md @@ -287,7 +287,6 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com | C406 | UnnecessaryLiteralDict | Unnecessary literal - rewrite as a dict literal | | | | C408 | UnnecessaryCollectionCall | Unnecessary call - rewrite as a literal | | | | C415 | UnnecessarySubscriptReversal | Unnecessary subscript reversal of iterable within () | | | -| SPR001 | SuperCallWithParameters | Use `super()` instead of `super(__class__, self)` | | 🛠 | | T201 | PrintFound | `print` found | | 🛠 | | T203 | PPrintFound | `pprint` found | | 🛠 | | U001 | UselessMetaclassType | `__metaclass__ = type` is implied | | 🛠 | @@ -297,6 +296,7 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com | U005 | NoAssertEquals | `assertEquals` is deprecated, use `assertEqual` instead | | 🛠 | | U006 | UsePEP585Annotation | Use `list` instead of `List` for type annotations | | 🛠 | | U007 | UsePEP604Annotation | Use `X \| Y` for type annotations | | 🛠 | +| U008 | SuperCallWithParameters | Use `super()` instead of `super(__class__, self)` | | 🛠 | | M001 | UnusedNOQA | Unused `noqa` directive | | 🛠 | ## Integrations diff --git a/resources/test/fixtures/SPR001.py b/resources/test/fixtures/U008.py similarity index 100% rename from resources/test/fixtures/SPR001.py rename to resources/test/fixtures/U008.py diff --git a/src/check_ast.rs b/src/check_ast.rs index 926b385034..fb4f5d67a1 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -730,7 +730,7 @@ where } // flake8-super - if self.settings.enabled.contains(&CheckCode::SPR001) { + if self.settings.enabled.contains(&CheckCode::U008) { plugins::super_call_with_parameters(self, expr, func, args); } diff --git a/src/checks.rs b/src/checks.rs index 03ccfa3b65..3c8a678a50 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -130,8 +130,6 @@ pub enum CheckCode { C406, C408, C415, - // flake8-super - SPR001, // flake8-print T201, T203, @@ -143,6 +141,7 @@ pub enum CheckCode { U005, U006, U007, + U008, // Meta M001, } @@ -221,8 +220,6 @@ pub enum CheckKind { UnnecessaryLiteralDict(String), UnnecessaryCollectionCall(String), UnnecessarySubscriptReversal(String), - // flake8-super - SuperCallWithParameters, // flake8-print PrintFound, PPrintFound, @@ -234,6 +231,7 @@ pub enum CheckKind { UselessObjectInheritance(String), UsePEP585Annotation(String), UsePEP604Annotation, + SuperCallWithParameters, // Meta UnusedNOQA(Option), } @@ -317,8 +315,6 @@ impl CheckCode { CheckCode::C415 => { CheckKind::UnnecessarySubscriptReversal("".to_string()) } - // flake8-super - CheckCode::SPR001 => CheckKind::SuperCallWithParameters, // flake8-print CheckCode::T201 => CheckKind::PrintFound, CheckCode::T203 => CheckKind::PPrintFound, @@ -330,6 +326,7 @@ impl CheckCode { CheckCode::U005 => CheckKind::NoAssertEquals, CheckCode::U006 => CheckKind::UsePEP585Annotation("List".to_string()), CheckCode::U007 => CheckKind::UsePEP604Annotation, + CheckCode::U008 => CheckKind::SuperCallWithParameters, // Meta CheckCode::M001 => CheckKind::UnusedNOQA(None), } @@ -399,8 +396,6 @@ impl CheckKind { CheckKind::UnnecessaryLiteralDict(_) => &CheckCode::C406, CheckKind::UnnecessaryCollectionCall(_) => &CheckCode::C408, CheckKind::UnnecessarySubscriptReversal(_) => &CheckCode::C415, - // flake8-super - CheckKind::SuperCallWithParameters => &CheckCode::SPR001, // flake8-print CheckKind::PrintFound => &CheckCode::T201, CheckKind::PPrintFound => &CheckCode::T203, @@ -412,6 +407,7 @@ impl CheckKind { CheckKind::UsePEP585Annotation(_) => &CheckCode::U006, CheckKind::UsePEP604Annotation => &CheckCode::U007, CheckKind::UselessObjectInheritance(_) => &CheckCode::U004, + CheckKind::SuperCallWithParameters => &CheckCode::U008, // Meta CheckKind::UnusedNOQA(_) => &CheckCode::M001, } @@ -588,10 +584,6 @@ impl CheckKind { CheckKind::UnnecessarySubscriptReversal(func) => { format!("Unnecessary subscript reversal of iterable within {func}()") } - // flake8-super - CheckKind::SuperCallWithParameters => { - "Use `super()` instead of `super(__class__, self)`".to_string() - } // flake8-print CheckKind::PrintFound => "`print` found".to_string(), CheckKind::PPrintFound => "`pprint` found".to_string(), @@ -617,6 +609,9 @@ impl CheckKind { ) } CheckKind::UsePEP604Annotation => "Use `X | Y` for type annotations".to_string(), + CheckKind::SuperCallWithParameters => { + "Use `super()` instead of `super(__class__, self)`".to_string() + } // Meta CheckKind::UnusedNOQA(code) => match code { None => "Unused `noqa` directive".to_string(), diff --git a/src/linter.rs b/src/linter.rs index bb159a9dce..bd6dd11cc2 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -955,10 +955,10 @@ mod tests { } #[test] - fn spr001() -> Result<()> { + fn u008() -> Result<()> { let mut checks = check_path( - Path::new("./resources/test/fixtures/SPR001.py"), - &settings::Settings::for_rule(CheckCode::SPR001), + Path::new("./resources/test/fixtures/U008.py"), + &settings::Settings::for_rule(CheckCode::U008), &fixer::Mode::Generate, )?; checks.sort_by_key(|check| check.location); diff --git a/src/snapshots/ruff__linter__tests__u008.snap b/src/snapshots/ruff__linter__tests__u008.snap new file mode 100644 index 0000000000..16afacfaeb --- /dev/null +++ b/src/snapshots/ruff__linter__tests__u008.snap @@ -0,0 +1,85 @@ +--- +source: src/linter.rs +expression: checks +--- +- kind: SuperCallWithParameters + location: + row: 17 + column: 18 + end_location: + row: 17 + column: 36 + fix: + content: super() + location: + row: 17 + column: 18 + end_location: + row: 17 + column: 36 + applied: false +- kind: SuperCallWithParameters + location: + row: 18 + column: 9 + end_location: + row: 18 + column: 27 + fix: + content: super() + location: + row: 18 + column: 9 + end_location: + row: 18 + column: 27 + applied: false +- kind: SuperCallWithParameters + location: + row: 19 + column: 9 + end_location: + row: 22 + column: 10 + fix: + content: super() + location: + row: 19 + column: 9 + end_location: + row: 22 + column: 10 + applied: false +- kind: SuperCallWithParameters + location: + row: 36 + column: 9 + end_location: + row: 36 + column: 29 + fix: + content: super() + location: + row: 36 + column: 9 + end_location: + row: 36 + column: 29 + applied: false +- kind: SuperCallWithParameters + location: + row: 50 + column: 13 + end_location: + row: 50 + column: 33 + fix: + content: super() + location: + row: 50 + column: 13 + end_location: + row: 50 + column: 33 + applied: false +