diff --git a/README.md b/README.md index 5044d42cc6..618e41cd14 100644 --- a/README.md +++ b/README.md @@ -1127,11 +1127,11 @@ For more, see [flake8-pie](https://pypi.org/project/flake8-pie/) on PyPI. | Code | Name | Message | Fix | | ---- | ---- | ------- | --- | -| PIE790 | no-unnecessary-pass | Unnecessary `pass` statement | 🛠 | +| PIE790 | unnecessary-pass | Unnecessary `pass` statement | 🛠 | | PIE794 | dupe-class-field-definitions | Class field `{name}` is defined multiple times | 🛠 | | PIE796 | prefer-unique-enums | Enum contains duplicate value: `{value}` | | -| PIE800 | no-unnecessary-spread | Unnecessary spread `**` | | -| PIE804 | no-unnecessary-dict-kwargs | Unnecessary `dict` kwargs | | +| PIE800 | unnecessary-spread | Unnecessary spread `**` | | +| PIE804 | unnecessary-dict-kwargs | Unnecessary `dict` kwargs | | | PIE807 | prefer-list-builtin | Prefer `list` over useless lambda | 🛠 | | PIE810 | single-starts-ends-with | Call `{attr}` once with a `tuple` | | diff --git a/crates/ruff/src/checkers/ast.rs b/crates/ruff/src/checkers/ast.rs index 9e3930e196..4db70578d4 100644 --- a/crates/ruff/src/checkers/ast.rs +++ b/crates/ruff/src/checkers/ast.rs @@ -2363,7 +2363,7 @@ where } // flake8-pie - if self.settings.rules.enabled(&Rule::NoUnnecessaryDictKwargs) { + if self.settings.rules.enabled(&Rule::UnnecessaryDictKwargs) { flake8_pie::rules::no_unnecessary_dict_kwargs(self, expr, keywords); } @@ -2781,7 +2781,7 @@ where pyflakes::rules::repeated_keys(self, keys, values); } - if self.settings.rules.enabled(&Rule::NoUnnecessarySpread) { + if self.settings.rules.enabled(&Rule::UnnecessarySpread) { flake8_pie::rules::no_unnecessary_spread(self, keys, values); } } @@ -3767,7 +3767,7 @@ where } fn visit_body(&mut self, body: &'b [Stmt]) { - if self.settings.rules.enabled(&Rule::NoUnnecessaryPass) { + if self.settings.rules.enabled(&Rule::UnnecessaryPass) { flake8_pie::rules::no_unnecessary_pass(self, body); } diff --git a/crates/ruff/src/registry.rs b/crates/ruff/src/registry.rs index ad9de6d31c..971a8b5d89 100644 --- a/crates/ruff/src/registry.rs +++ b/crates/ruff/src/registry.rs @@ -474,11 +474,11 @@ ruff_macros::define_rule_mapping!( PT025 => rules::flake8_pytest_style::rules::ErroneousUseFixturesOnFixture, PT026 => rules::flake8_pytest_style::rules::UseFixturesWithoutParameters, // flake8-pie - PIE790 => rules::flake8_pie::rules::NoUnnecessaryPass, + PIE790 => rules::flake8_pie::rules::UnnecessaryPass, PIE794 => rules::flake8_pie::rules::DupeClassFieldDefinitions, PIE796 => rules::flake8_pie::rules::PreferUniqueEnums, - PIE800 => rules::flake8_pie::rules::NoUnnecessarySpread, - PIE804 => rules::flake8_pie::rules::NoUnnecessaryDictKwargs, + PIE800 => rules::flake8_pie::rules::UnnecessarySpread, + PIE804 => rules::flake8_pie::rules::UnnecessaryDictKwargs, PIE807 => rules::flake8_pie::rules::PreferListBuiltin, PIE810 => rules::flake8_pie::rules::SingleStartsEndsWith, // flake8-commas diff --git a/crates/ruff/src/rules/flake8_pie/mod.rs b/crates/ruff/src/rules/flake8_pie/mod.rs index 378b611140..c804e48bd8 100644 --- a/crates/ruff/src/rules/flake8_pie/mod.rs +++ b/crates/ruff/src/rules/flake8_pie/mod.rs @@ -13,10 +13,10 @@ mod tests { use crate::{assert_yaml_snapshot, settings}; #[test_case(Rule::DupeClassFieldDefinitions, Path::new("PIE794.py"); "PIE794")] - #[test_case(Rule::NoUnnecessaryDictKwargs, Path::new("PIE804.py"); "PIE804")] + #[test_case(Rule::UnnecessaryDictKwargs, Path::new("PIE804.py"); "PIE804")] #[test_case(Rule::SingleStartsEndsWith, Path::new("PIE810.py"); "PIE810")] - #[test_case(Rule::NoUnnecessaryPass, Path::new("PIE790.py"); "PIE790")] - #[test_case(Rule::NoUnnecessarySpread, Path::new("PIE800.py"); "PIE800")] + #[test_case(Rule::UnnecessaryPass, Path::new("PIE790.py"); "PIE790")] + #[test_case(Rule::UnnecessarySpread, Path::new("PIE800.py"); "PIE800")] #[test_case(Rule::PreferListBuiltin, Path::new("PIE807.py"); "PIE807")] #[test_case(Rule::PreferUniqueEnums, Path::new("PIE796.py"); "PIE796")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { diff --git a/crates/ruff/src/rules/flake8_pie/rules.rs b/crates/ruff/src/rules/flake8_pie/rules.rs index ee8ed2f8ff..0d96bd4966 100644 --- a/crates/ruff/src/rules/flake8_pie/rules.rs +++ b/crates/ruff/src/rules/flake8_pie/rules.rs @@ -16,9 +16,9 @@ use crate::registry::Diagnostic; use crate::violation::{AlwaysAutofixableViolation, Violation}; define_violation!( - pub struct NoUnnecessaryPass; + pub struct UnnecessaryPass; ); -impl AlwaysAutofixableViolation for NoUnnecessaryPass { +impl AlwaysAutofixableViolation for UnnecessaryPass { #[derive_message_formats] fn message(&self) -> String { format!("Unnecessary `pass` statement") @@ -59,9 +59,9 @@ impl Violation for PreferUniqueEnums { } define_violation!( - pub struct NoUnnecessarySpread; + pub struct UnnecessarySpread; ); -impl Violation for NoUnnecessarySpread { +impl Violation for UnnecessarySpread { #[derive_message_formats] fn message(&self) -> String { format!("Unnecessary spread `**`") @@ -82,9 +82,9 @@ impl Violation for SingleStartsEndsWith { } define_violation!( - pub struct NoUnnecessaryDictKwargs; + pub struct UnnecessaryDictKwargs; ); -impl Violation for NoUnnecessaryDictKwargs { +impl Violation for UnnecessaryDictKwargs { #[derive_message_formats] fn message(&self) -> String { format!("Unnecessary `dict` kwargs") @@ -124,7 +124,7 @@ pub fn no_unnecessary_pass(checker: &mut Checker, body: &[Stmt]) { ) { if matches!(pass_stmt.node, StmtKind::Pass) { let mut diagnostic = - Diagnostic::new(NoUnnecessaryPass, Range::from_located(pass_stmt)); + Diagnostic::new(UnnecessaryPass, Range::from_located(pass_stmt)); if checker.patch(diagnostic.kind.rule()) { if let Some(index) = match_trailing_comment(pass_stmt, checker.locator) { diagnostic.amend(Fix::deletion( @@ -275,7 +275,7 @@ pub fn no_unnecessary_spread(checker: &mut Checker, keys: &[Option], value // We only care about when the key is None which indicates a spread `**` // inside a dict. if let ExprKind::Dict { .. } = value.node { - let diagnostic = Diagnostic::new(NoUnnecessarySpread, Range::from_located(value)); + let diagnostic = Diagnostic::new(UnnecessarySpread, Range::from_located(value)); checker.diagnostics.push(diagnostic); } } @@ -307,7 +307,7 @@ pub fn no_unnecessary_dict_kwargs(checker: &mut Checker, expr: &Expr, kwargs: &[ (keys.len() == 1 && keys[0].is_none()) { let diagnostic = - Diagnostic::new(NoUnnecessaryDictKwargs, Range::from_located(expr)); + Diagnostic::new(UnnecessaryDictKwargs, Range::from_located(expr)); checker.diagnostics.push(diagnostic); } } diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap index b7768fa39d..4c0b5d866a 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap @@ -1,9 +1,9 @@ --- -source: src/rules/flake8_pie/mod.rs +source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 4 column: 4 @@ -21,7 +21,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 9 column: 4 @@ -39,7 +39,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 14 column: 4 @@ -57,7 +57,7 @@ expression: diagnostics column: 10 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 21 column: 4 @@ -75,7 +75,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 28 column: 4 @@ -93,7 +93,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 35 column: 4 @@ -111,7 +111,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 42 column: 4 @@ -129,7 +129,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 50 column: 4 @@ -147,7 +147,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 58 column: 4 @@ -165,7 +165,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 65 column: 4 @@ -183,7 +183,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 74 column: 4 @@ -201,7 +201,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 79 column: 4 @@ -219,7 +219,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 83 column: 4 @@ -237,7 +237,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 87 column: 4 @@ -255,7 +255,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 92 column: 4 @@ -273,7 +273,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 96 column: 4 @@ -291,7 +291,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - NoUnnecessaryPass: ~ + UnnecessaryPass: ~ location: row: 101 column: 4 diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap index ed8d3d4c96..f5517f4003 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap @@ -1,9 +1,9 @@ --- -source: src/rules/flake8_pie/mod.rs +source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - NoUnnecessarySpread: ~ + UnnecessarySpread: ~ location: row: 1 column: 13 @@ -13,7 +13,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessarySpread: ~ + UnnecessarySpread: ~ location: row: 3 column: 14 @@ -23,7 +23,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessarySpread: ~ + UnnecessarySpread: ~ location: row: 5 column: 10 @@ -33,7 +33,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessarySpread: ~ + UnnecessarySpread: ~ location: row: 7 column: 18 diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap index ba710b6c68..2834085f7c 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap @@ -1,9 +1,9 @@ --- -source: src/rules/flake8_pie/mod.rs +source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - NoUnnecessaryDictKwargs: ~ + UnnecessaryDictKwargs: ~ location: row: 1 column: 0 @@ -13,7 +13,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessaryDictKwargs: ~ + UnnecessaryDictKwargs: ~ location: row: 3 column: 0 @@ -23,7 +23,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessaryDictKwargs: ~ + UnnecessaryDictKwargs: ~ location: row: 5 column: 0 @@ -33,7 +33,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessaryDictKwargs: ~ + UnnecessaryDictKwargs: ~ location: row: 7 column: 0 @@ -43,7 +43,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - NoUnnecessaryDictKwargs: ~ + UnnecessaryDictKwargs: ~ location: row: 9 column: 0