diff --git a/crates/ruff/resources/test/disallowed_rule_names.txt b/crates/ruff/resources/test/disallowed_rule_names.txt index b2255956fe..20cbe78efb 100644 --- a/crates/ruff/resources/test/disallowed_rule_names.txt +++ b/crates/ruff/resources/test/disallowed_rule_names.txt @@ -2,3 +2,6 @@ avoid-* do-not-* uses-* *-used +rewrite-* +prefer-* +consider-* diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_merging_isinstance.py b/crates/ruff/resources/test/fixtures/pylint/repeated_isinstance_calls.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_merging_isinstance.py rename to crates/ruff/resources/test/fixtures/pylint/repeated_isinstance_calls.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_0.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_0.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_0.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_1.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_1.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_1.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_2.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_2.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_2.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_3.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_3.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_3.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_4.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_4.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_4.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_5.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_5.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_5.py diff --git a/crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_6.py b/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/consider_using_sys_exit_6.py rename to crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_6.py diff --git a/crates/ruff/resources/test/fixtures/pylint/used_prior_global_declaration.py b/crates/ruff/resources/test/fixtures/pylint/use_prior_to_global_declaration.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/used_prior_global_declaration.py rename to crates/ruff/resources/test/fixtures/pylint/use_prior_to_global_declaration.py diff --git a/crates/ruff/src/autofix/mod.rs b/crates/ruff/src/autofix/mod.rs index d6e2e4bb84..dc49cdb2dc 100644 --- a/crates/ruff/src/autofix/mod.rs +++ b/crates/ruff/src/autofix/mod.rs @@ -113,14 +113,14 @@ mod tests { use ruff_python_ast::source_code::Locator; use crate::autofix::{apply_fix, apply_fixes}; - use crate::rules::pycodestyle::rules::NoNewLineAtEndOfFile; + use crate::rules::pycodestyle::rules::MissingNewlineAtEndOfFile; fn create_diagnostics(fixes: impl IntoIterator) -> Vec { fixes .into_iter() .map(|fix| Diagnostic { // The choice of rule here is arbitrary. - kind: NoNewLineAtEndOfFile.into(), + kind: MissingNewlineAtEndOfFile.into(), location: fix.location, end_location: fix.end_location, fix: Some(fix), diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index d984b21289..b8b3317baa 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -316,7 +316,7 @@ where if self .settings .rules - .enabled(Rule::NonLeadingReceiverDecorator) + .enabled(Rule::DjangoNonLeadingReceiverDecorator) { self.diagnostics .extend(flake8_django::rules::non_leading_receiver_decorator( @@ -410,10 +410,10 @@ where { pyupgrade::rules::lru_cache_without_parameters(self, decorator_list); } - if self.settings.rules.enabled(Rule::FunctoolsCache) + if self.settings.rules.enabled(Rule::LRUCacheWithMaxsizeNone) && self.settings.target_version >= PythonVersion::Py39 { - pyupgrade::rules::functools_cache(self, decorator_list); + pyupgrade::rules::lru_cache_with_maxsize_none(self, decorator_list); } if self.settings.rules.enabled(Rule::UselessExpression) { @@ -501,29 +501,44 @@ where if self .settings .rules - .enabled(Rule::IncorrectFixtureParenthesesStyle) - || self.settings.rules.enabled(Rule::FixturePositionalArgs) - || self.settings.rules.enabled(Rule::ExtraneousScopeFunction) + .enabled(Rule::PytestFixtureIncorrectParenthesesStyle) || self .settings .rules - .enabled(Rule::MissingFixtureNameUnderscore) + .enabled(Rule::PytestFixturePositionalArgs) || self .settings .rules - .enabled(Rule::IncorrectFixtureNameUnderscore) - || self.settings.rules.enabled(Rule::FixtureParamWithoutValue) - || self.settings.rules.enabled(Rule::DeprecatedYieldFixture) - || self.settings.rules.enabled(Rule::FixtureFinalizerCallback) - || self.settings.rules.enabled(Rule::UselessYieldFixture) + .enabled(Rule::PytestExtraneousScopeFunction) || self .settings .rules - .enabled(Rule::UnnecessaryAsyncioMarkOnFixture) + .enabled(Rule::PytestMissingFixtureNameUnderscore) || self .settings .rules - .enabled(Rule::ErroneousUseFixturesOnFixture) + .enabled(Rule::PytestIncorrectFixtureNameUnderscore) + || self + .settings + .rules + .enabled(Rule::PytestFixtureParamWithoutValue) + || self + .settings + .rules + .enabled(Rule::PytestDeprecatedYieldFixture) + || self + .settings + .rules + .enabled(Rule::PytestFixtureFinalizerCallback) + || self.settings.rules.enabled(Rule::PytestUselessYieldFixture) + || self + .settings + .rules + .enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture) + || self + .settings + .rules + .enabled(Rule::PytestErroneousUseFixturesOnFixture) { flake8_pytest_style::rules::fixture( self, @@ -535,11 +550,14 @@ where ); } - if self.settings.rules.enabled(Rule::ParametrizeNamesWrongType) + if self + .settings + .rules + .enabled(Rule::PytestParametrizeNamesWrongType) || self .settings .rules - .enabled(Rule::ParametrizeValuesWrongType) + .enabled(Rule::PytestParametrizeValuesWrongType) { flake8_pytest_style::rules::parametrize(self, decorator_list); } @@ -547,11 +565,11 @@ where if self .settings .rules - .enabled(Rule::IncorrectMarkParenthesesStyle) + .enabled(Rule::PytestIncorrectMarkParenthesesStyle) || self .settings .rules - .enabled(Rule::UseFixturesWithoutParameters) + .enabled(Rule::PytestUseFixturesWithoutParameters) { flake8_pytest_style::rules::marks(self, decorator_list); } @@ -687,28 +705,40 @@ where decorator_list, body, } => { - if self.settings.rules.enabled(Rule::NullableModelStringField) { + if self + .settings + .rules + .enabled(Rule::DjangoNullableModelStringField) + { self.diagnostics .extend(flake8_django::rules::nullable_model_string_field( self, body, )); } - if self.settings.rules.enabled(Rule::ExcludeWithModelForm) { + if self + .settings + .rules + .enabled(Rule::DjangoExcludeWithModelForm) + { if let Some(diagnostic) = flake8_django::rules::exclude_with_model_form(self, bases, body) { self.diagnostics.push(diagnostic); } } - if self.settings.rules.enabled(Rule::AllWithModelForm) { + if self.settings.rules.enabled(Rule::DjangoAllWithModelForm) { if let Some(diagnostic) = flake8_django::rules::all_with_model_form(self, bases, body) { self.diagnostics.push(diagnostic); } } - if self.settings.rules.enabled(Rule::ModelWithoutDunderStr) { + if self + .settings + .rules + .enabled(Rule::DjangoModelWithoutDunderStr) + { if let Some(diagnostic) = flake8_django::rules::model_without_dunder_str(self, bases, body, stmt) { @@ -781,17 +811,21 @@ where if self .settings .rules - .enabled(Rule::IncorrectMarkParenthesesStyle) + .enabled(Rule::PytestIncorrectMarkParenthesesStyle) { flake8_pytest_style::rules::marks(self, decorator_list); } - if self.settings.rules.enabled(Rule::DupeClassFieldDefinitions) { - flake8_pie::rules::dupe_class_field_definitions(self, stmt, body); + if self + .settings + .rules + .enabled(Rule::DuplicateClassFieldDefinition) + { + flake8_pie::rules::duplicate_class_field_definition(self, stmt, body); } - if self.settings.rules.enabled(Rule::PreferUniqueEnums) { - flake8_pie::rules::prefer_unique_enums(self, stmt, body); + if self.settings.rules.enabled(Rule::NonUniqueEnums) { + flake8_pie::rules::non_unique_enums(self, stmt, body); } self.check_builtin_shadowing(name, stmt, false); @@ -828,11 +862,11 @@ where } } - if self.settings.rules.enabled(Rule::RewriteCElementTree) { - pyupgrade::rules::replace_c_element_tree(self, stmt); + if self.settings.rules.enabled(Rule::DeprecatedCElementTree) { + pyupgrade::rules::deprecated_c_element_tree(self, stmt); } - if self.settings.rules.enabled(Rule::RewriteMockImport) { - pyupgrade::rules::rewrite_mock_import(self, stmt); + if self.settings.rules.enabled(Rule::DeprecatedMockImport) { + pyupgrade::rules::deprecated_mock_import(self, stmt); } // If a module is imported within a `ModuleNotFoundError` body, treat that as a @@ -951,8 +985,8 @@ where if self.settings.rules.enabled(Rule::UselessImportAlias) { pylint::rules::useless_import_alias(self, alias); } - if self.settings.rules.enabled(Rule::ConsiderUsingFromImport) { - pylint::rules::use_from_import(self, stmt, alias, names); + if self.settings.rules.enabled(Rule::ManualFromImport) { + pylint::rules::manual_from_import(self, stmt, alias, names); } if let Some(asname) = &alias.node.asname { @@ -1056,7 +1090,11 @@ where } } - if self.settings.rules.enabled(Rule::IncorrectPytestImport) { + if self + .settings + .rules + .enabled(Rule::PytestIncorrectPytestImport) + { if let Some(diagnostic) = flake8_pytest_style::rules::import( stmt, &alias.node.name, @@ -1097,11 +1135,11 @@ where pyupgrade::rules::unnecessary_future_import(self, stmt, names); } } - if self.settings.rules.enabled(Rule::RewriteMockImport) { - pyupgrade::rules::rewrite_mock_import(self, stmt); + if self.settings.rules.enabled(Rule::DeprecatedMockImport) { + pyupgrade::rules::deprecated_mock_import(self, stmt); } - if self.settings.rules.enabled(Rule::RewriteCElementTree) { - pyupgrade::rules::replace_c_element_tree(self, stmt); + if self.settings.rules.enabled(Rule::DeprecatedCElementTree) { + pyupgrade::rules::deprecated_c_element_tree(self, stmt); } if self.settings.rules.enabled(Rule::DeprecatedImport) { pyupgrade::rules::deprecated_import( @@ -1143,7 +1181,11 @@ where } } - if self.settings.rules.enabled(Rule::IncorrectPytestImport) { + if self + .settings + .rules + .enabled(Rule::PytestIncorrectPytestImport) + { if let Some(diagnostic) = flake8_pytest_style::rules::import_from( stmt, module.as_deref(), @@ -1212,11 +1254,15 @@ where }, ); - if self.settings.rules.enabled(Rule::ImportStarNotPermitted) { + if self + .settings + .rules + .enabled(Rule::UndefinedLocalWithNestedImportStarUsage) + { let scope = self.ctx.scope(); if !matches!(scope.kind, ScopeKind::Module) { self.diagnostics.push(Diagnostic::new( - pyflakes::rules::ImportStarNotPermitted { + pyflakes::rules::UndefinedLocalWithNestedImportStarUsage { name: helpers::format_import_from( level.as_ref(), module.as_deref(), @@ -1227,9 +1273,13 @@ where } } - if self.settings.rules.enabled(Rule::ImportStar) { + if self + .settings + .rules + .enabled(Rule::UndefinedLocalWithImportStar) + { self.diagnostics.push(Diagnostic::new( - pyflakes::rules::ImportStar { + pyflakes::rules::UndefinedLocalWithImportStar { name: helpers::format_import_from( level.as_ref(), module.as_deref(), @@ -1496,7 +1546,11 @@ where if self.settings.rules.enabled(Rule::NeedlessBool) { flake8_simplify::rules::needless_bool(self, stmt); } - if self.settings.rules.enabled(Rule::ManualDictLookup) { + if self + .settings + .rules + .enabled(Rule::IfElseBlockInsteadOfDictLookup) + { flake8_simplify::rules::manual_dict_lookup( self, stmt, @@ -1506,14 +1560,18 @@ where self.ctx.current_stmt_parent().map(Into::into), ); } - if self.settings.rules.enabled(Rule::UseTernaryOperator) { + if self.settings.rules.enabled(Rule::IfElseBlockInsteadOfIfExp) { flake8_simplify::rules::use_ternary_operator( self, stmt, self.ctx.current_stmt_parent().map(Into::into), ); } - if self.settings.rules.enabled(Rule::DictGetWithDefault) { + if self + .settings + .rules + .enabled(Rule::IfElseBlockInsteadOfDictGet) + { flake8_simplify::rules::use_dict_get_with_default( self, stmt, @@ -1523,8 +1581,8 @@ where self.ctx.current_stmt_parent().map(Into::into), ); } - if self.settings.rules.enabled(Rule::PreferTypeError) { - tryceratops::rules::prefer_type_error( + if self.settings.rules.enabled(Rule::TypeCheckWithoutTypeError) { + tryceratops::rules::type_check_without_type_error( self, body, test, @@ -1554,12 +1612,12 @@ where self.diagnostics .push(flake8_bandit::rules::assert_used(stmt)); } - if self.settings.rules.enabled(Rule::AssertAlwaysFalse) { + if self.settings.rules.enabled(Rule::PytestAssertAlwaysFalse) { if let Some(diagnostic) = flake8_pytest_style::rules::assert_falsy(stmt, test) { self.diagnostics.push(diagnostic); } } - if self.settings.rules.enabled(Rule::CompositeAssertion) { + if self.settings.rules.enabled(Rule::PytestCompositeAssertion) { flake8_pytest_style::rules::composite_condition( self, stmt, @@ -1575,7 +1633,7 @@ where if self .settings .rules - .enabled(Rule::RaisesWithMultipleStatements) + .enabled(Rule::PytestRaisesWithMultipleStatements) { flake8_pytest_style::rules::complex_raises(self, stmt, items, body); } @@ -1643,7 +1701,7 @@ where self.ctx.current_sibling_stmt(), ); } - if self.settings.rules.enabled(Rule::KeyInDict) { + if self.settings.rules.enabled(Rule::InDictKeys) { flake8_simplify::rules::key_in_dict_for(self, target, iter); } } @@ -1687,7 +1745,7 @@ where if self.settings.rules.enabled(Rule::OSErrorAlias) { pyupgrade::rules::os_error_alias_handlers(self, handlers); } - if self.settings.rules.enabled(Rule::AssertInExcept) { + if self.settings.rules.enabled(Rule::PytestAssertInExcept) { self.diagnostics.extend( flake8_pytest_style::rules::assert_in_exception_handler(handlers), ); @@ -1738,7 +1796,7 @@ where } if self.is_stub { - if self.settings.rules.enabled(Rule::PrefixTypeParams) { + if self.settings.rules.enabled(Rule::UnprefixedTypeParam) { flake8_pyi::rules::prefix_type_params(self, value, targets); } } @@ -1772,11 +1830,11 @@ where self, stmt, targets, value, ); } - if self.settings.rules.enabled(Rule::RewriteListComprehension) { - pyupgrade::rules::unpack_list_comprehension(self, targets, value); + if self.settings.rules.enabled(Rule::UnpackedListComprehension) { + pyupgrade::rules::unpacked_list_comprehension(self, targets, value); } - if self.settings.rules.enabled(Rule::DfIsABadVariableName) { + if self.settings.rules.enabled(Rule::PandasDfVariableName) { if let Some(diagnostic) = pandas_vet::rules::assignment_to_df(targets) { self.diagnostics.push(diagnostic); } @@ -1817,7 +1875,7 @@ where if self .settings .rules - .enabled(Rule::UseCapitalEnvironmentVariables) + .enabled(Rule::UncapitalizedEnvironmentVariables) { flake8_simplify::rules::use_capital_environment_variables(self, value); } @@ -1859,8 +1917,8 @@ where body, &Documentable::Function, ); - if self.settings.rules.enabled(Rule::RewriteYieldFrom) { - pyupgrade::rules::rewrite_yield_from(self, stmt); + if self.settings.rules.enabled(Rule::YieldInForLoop) { + pyupgrade::rules::yield_in_for_loop(self, stmt); } let scope = transition_scope(&self.ctx.visible_scope, stmt, &Documentable::Function); @@ -2166,16 +2224,10 @@ where self.ctx.in_literal = true; } - if self - .settings - .rules - .enabled(Rule::SysVersionSlice3Referenced) - || self.settings.rules.enabled(Rule::SysVersion2Referenced) - || self.settings.rules.enabled(Rule::SysVersion0Referenced) - || self - .settings - .rules - .enabled(Rule::SysVersionSlice1Referenced) + if self.settings.rules.enabled(Rule::SysVersionSlice3) + || self.settings.rules.enabled(Rule::SysVersion2) + || self.settings.rules.enabled(Rule::SysVersion0) + || self.settings.rules.enabled(Rule::SysVersionSlice1) { flake8_2020::rules::subscript(self, value, slice); } @@ -2186,8 +2238,10 @@ where .settings .rules .enabled(Rule::ExpressionsInStarAssignment); - let check_two_starred_expressions = - self.settings.rules.enabled(Rule::TwoStarredExpressions); + let check_two_starred_expressions = self + .settings + .rules + .enabled(Rule::MultipleStarredExpressions); if let Some(diagnostic) = pyflakes::rules::starred_expressions( elts, check_too_many_expressions, @@ -2241,16 +2295,16 @@ where ExprContext::Del => self.handle_node_delete(expr), } - if self.settings.rules.enabled(Rule::SixPY3Referenced) { + if self.settings.rules.enabled(Rule::SixPY3) { flake8_2020::rules::name_or_attribute(self, expr); } if self .settings .rules - .enabled(Rule::UsedPriorGlobalDeclaration) + .enabled(Rule::UsePriorToGlobalDeclaration) { - pylint::rules::used_prior_global_declaration(self, id, expr); + pylint::rules::use_prior_to_global_declaration(self, id, expr); } } ExprKind::Attribute { attr, value, .. } => { @@ -2277,10 +2331,10 @@ where if self.settings.rules.enabled(Rule::NumpyDeprecatedTypeAlias) { numpy::rules::deprecated_type_alias(self, expr); } - if self.settings.rules.enabled(Rule::RewriteMockImport) { - pyupgrade::rules::rewrite_mock_attribute(self, expr); + if self.settings.rules.enabled(Rule::DeprecatedMockImport) { + pyupgrade::rules::deprecated_mock_attribute(self, expr); } - if self.settings.rules.enabled(Rule::SixPY3Referenced) { + if self.settings.rules.enabled(Rule::SixPY3) { flake8_2020::rules::name_or_attribute(self, expr); } if self.settings.rules.enabled(Rule::BannedApi) { @@ -2424,8 +2478,8 @@ where } // flake8-print - if self.settings.rules.enabled(Rule::PrintFound) - || self.settings.rules.enabled(Rule::PPrintFound) + if self.settings.rules.enabled(Rule::Print) + || self.settings.rules.enabled(Rule::PPrint) { flake8_print::rules::print_call(self, func, keywords); } @@ -2466,7 +2520,7 @@ where // flake8-pie if self.settings.rules.enabled(Rule::UnnecessaryDictKwargs) { - flake8_pie::rules::no_unnecessary_dict_kwargs(self, expr, keywords); + flake8_pie::rules::unnecessary_dict_kwargs(self, expr, keywords); } if self .settings @@ -2680,14 +2734,18 @@ where } // pandas-vet - if self.settings.rules.enabled(Rule::UseOfInplaceArgument) { + if self + .settings + .rules + .enabled(Rule::PandasUseOfInplaceArgument) + { self.diagnostics.extend( pandas_vet::rules::inplace_argument(self, expr, args, keywords).into_iter(), ); } pandas_vet::rules::check_call(self, func); - if self.settings.rules.enabled(Rule::UseOfPdMerge) { + if self.settings.rules.enabled(Rule::PandasUseOfPdMerge) { if let Some(diagnostic) = pandas_vet::rules::use_of_pd_merge(func) { self.diagnostics.push(diagnostic); }; @@ -2762,7 +2820,7 @@ where } // pygrep-hooks - if self.settings.rules.enabled(Rule::NoEval) { + if self.settings.rules.enabled(Rule::Eval) { pygrep_hooks::rules::no_eval(self, func); } if self.settings.rules.enabled(Rule::DeprecatedLogWarn) { @@ -2777,8 +2835,8 @@ where { pylint::rules::unnecessary_direct_lambda_call(self, expr, func); } - if self.settings.rules.enabled(Rule::ConsiderUsingSysExit) { - pylint::rules::consider_using_sys_exit(self, func); + if self.settings.rules.enabled(Rule::SysExitAlias) { + pylint::rules::sys_exit_alias(self, func); } if self.settings.rules.enabled(Rule::BadStrStripCall) { pylint::rules::bad_str_strip_call(self, func, args); @@ -2791,14 +2849,14 @@ where } // flake8-pytest-style - if self.settings.rules.enabled(Rule::PatchWithLambda) { + if self.settings.rules.enabled(Rule::PytestPatchWithLambda) { if let Some(diagnostic) = flake8_pytest_style::rules::patch_with_lambda(func, args, keywords) { self.diagnostics.push(diagnostic); } } - if self.settings.rules.enabled(Rule::UnittestAssertion) { + if self.settings.rules.enabled(Rule::PytestUnittestAssertion) { if let Some(diagnostic) = flake8_pytest_style::rules::unittest_assertion( self, expr, func, args, keywords, ) { @@ -2806,13 +2864,16 @@ where } } - if self.settings.rules.enabled(Rule::RaisesWithoutException) - || self.settings.rules.enabled(Rule::RaisesTooBroad) + if self + .settings + .rules + .enabled(Rule::PytestRaisesWithoutException) + || self.settings.rules.enabled(Rule::PytestRaisesTooBroad) { flake8_pytest_style::rules::raises_call(self, func, args, keywords); } - if self.settings.rules.enabled(Rule::FailWithoutMessage) { + if self.settings.rules.enabled(Rule::PytestFailWithoutMessage) { flake8_pytest_style::rules::fail_call(self, func, args, keywords); } @@ -2886,7 +2947,11 @@ where } // flake8-django - if self.settings.rules.enabled(Rule::LocalsInRenderFunction) { + if self + .settings + .rules + .enabled(Rule::DjangoLocalsInRenderFunction) + { flake8_django::rules::locals_in_render_function(self, func, args, keywords); } } @@ -2904,7 +2969,7 @@ where } if self.settings.rules.enabled(Rule::UnnecessarySpread) { - flake8_pie::rules::no_unnecessary_spread(self, keys, values); + flake8_pie::rules::unnecessary_spread(self, keys, values); } } ExprKind::Yield { .. } => { @@ -3126,9 +3191,9 @@ where if self .settings .rules - .enabled(Rule::UnpackInsteadOfConcatenatingToCollectionLiteral) + .enabled(Rule::CollectionLiteralConcatenation) { - ruff::rules::unpack_instead_of_concatenating_to_collection_literal(self, expr); + ruff::rules::collection_literal_concatenation(self, expr); } if self.settings.rules.enabled(Rule::HardcodedSQLExpression) { flake8_bandit::rules::hardcoded_sql_expression(self, expr); @@ -3197,10 +3262,7 @@ where } if self.settings.rules.enabled(Rule::SysVersionCmpStr3) - || self - .settings - .rules - .enabled(Rule::SysVersionInfo0Eq3Referenced) + || self.settings.rules.enabled(Rule::SysVersionInfo0Eq3) || self.settings.rules.enabled(Rule::SysVersionInfo1CmpInt) || self.settings.rules.enabled(Rule::SysVersionInfoMinorCmpInt) || self.settings.rules.enabled(Rule::SysVersionCmpStr10) @@ -3229,7 +3291,7 @@ where pylint::rules::magic_value_comparison(self, left, comparators); } - if self.settings.rules.enabled(Rule::KeyInDict) { + if self.settings.rules.enabled(Rule::InDictKeys) { flake8_simplify::rules::key_in_dict_compare(self, expr, left, ops, comparators); } @@ -3294,13 +3356,13 @@ where self.diagnostics.push(diagnostic); } } - if self.settings.rules.enabled(Rule::RewriteUnicodeLiteral) { - pyupgrade::rules::rewrite_unicode_literal(self, expr, kind.as_deref()); + if self.settings.rules.enabled(Rule::UnicodeKindPrefix) { + pyupgrade::rules::unicode_kind_prefix(self, expr, kind.as_deref()); } } ExprKind::Lambda { args, body, .. } => { - if self.settings.rules.enabled(Rule::PreferListBuiltin) { - flake8_pie::rules::prefer_list_builtin(self, expr); + if self.settings.rules.enabled(Rule::ReimplementedListBuiltin) { + flake8_pie::rules::reimplemented_list_builtin(self, expr); } // Visit the default arguments, but avoid the body, which will be deferred. @@ -3346,11 +3408,11 @@ where self.ctx.push_scope(ScopeKind::Generator); } ExprKind::BoolOp { op, values } => { - if self.settings.rules.enabled(Rule::ConsiderMergingIsinstance) { - pylint::rules::merge_isinstance(self, expr, op, values); + if self.settings.rules.enabled(Rule::RepeatedIsinstanceCalls) { + pylint::rules::repeated_isinstance_calls(self, expr, op, values); } - if self.settings.rules.enabled(Rule::SingleStartsEndsWith) { - flake8_pie::rules::single_starts_ends_with(self, expr); + if self.settings.rules.enabled(Rule::MultipleStartsEndsWith) { + flake8_pie::rules::multiple_starts_ends_with(self, expr); } if self.settings.rules.enabled(Rule::DuplicateIsinstanceCall) { flake8_simplify::rules::duplicate_isinstance_call(self, expr); @@ -3623,7 +3685,7 @@ where } fn visit_comprehension(&mut self, comprehension: &'b Comprehension) { - if self.settings.rules.enabled(Rule::KeyInDict) { + if self.settings.rules.enabled(Rule::InDictKeys) { flake8_simplify::rules::key_in_dict_for( self, &comprehension.target, @@ -3805,7 +3867,7 @@ where if self .settings .rules - .enabled(Rule::FunctionCallArgumentDefault) + .enabled(Rule::FunctionCallInDefaultArgument) { flake8_bugbear::rules::function_call_argument_default(self, arguments); } @@ -3814,13 +3876,13 @@ where if self .settings .rules - .enabled(Rule::TypedArgumentSimpleDefaults) + .enabled(Rule::TypedArgumentDefaultInStub) { flake8_pyi::rules::typed_argument_simple_defaults(self, arguments); } } if self.is_stub { - if self.settings.rules.enabled(Rule::ArgumentSimpleDefaults) { + if self.settings.rules.enabled(Rule::ArgumentDefaultInStub) { flake8_pyi::rules::argument_simple_defaults(self, arguments); } } @@ -4172,7 +4234,11 @@ impl<'a> Checker<'a> { } if import_starred { - if self.settings.rules.enabled(Rule::ImportStarUsage) { + if self + .settings + .rules + .enabled(Rule::UndefinedLocalWithImportStarUsage) + { let mut from_list = vec![]; for scope_index in self.ctx.scope_stack.iter() { let scope = &self.ctx.scopes[*scope_index]; @@ -4188,7 +4254,7 @@ impl<'a> Checker<'a> { from_list.sort(); self.diagnostics.push(Diagnostic::new( - pyflakes::rules::ImportStarUsage { + pyflakes::rules::UndefinedLocalWithImportStarUsage { name: id.to_string(), sources: from_list, }, @@ -4648,7 +4714,10 @@ impl<'a> Checker<'a> { .enabled(Rule::TypingOnlyStandardLibraryImport)); if !(self.settings.rules.enabled(Rule::UnusedImport) - || self.settings.rules.enabled(Rule::ImportStarUsage) + || self + .settings + .rules + .enabled(Rule::UndefinedLocalWithImportStarUsage) || self.settings.rules.enabled(Rule::RedefinedWhileUnused) || self.settings.rules.enabled(Rule::UndefinedExport) || enforce_typing_imports) @@ -4809,7 +4878,11 @@ impl<'a> Checker<'a> { } } - if self.settings.rules.enabled(Rule::ImportStarUsage) { + if self + .settings + .rules + .enabled(Rule::UndefinedLocalWithImportStarUsage) + { if scope.import_starred { if let Some((names, range)) = &all_names { let mut from_list = vec![]; @@ -4826,7 +4899,7 @@ impl<'a> Checker<'a> { for &name in names { if !scope.defines(name) { diagnostics.push(Diagnostic::new( - pyflakes::rules::ImportStarUsage { + pyflakes::rules::UndefinedLocalWithImportStarUsage { name: name.to_string(), sources: from_list.clone(), }, @@ -5026,7 +5099,7 @@ impl<'a> Checker<'a> { || self .settings .rules - .enabled(Rule::MissingReturnTypePublicFunction) + .enabled(Rule::MissingReturnTypeUndocumentedPublicFunction) || self .settings .rules @@ -5044,14 +5117,20 @@ impl<'a> Checker<'a> { .rules .enabled(Rule::MissingReturnTypeClassMethod) || self.settings.rules.enabled(Rule::AnyType); - let enforce_docstrings = self.settings.rules.enabled(Rule::PublicModule) - || self.settings.rules.enabled(Rule::PublicClass) - || self.settings.rules.enabled(Rule::PublicMethod) - || self.settings.rules.enabled(Rule::PublicFunction) - || self.settings.rules.enabled(Rule::PublicPackage) - || self.settings.rules.enabled(Rule::MagicMethod) - || self.settings.rules.enabled(Rule::PublicNestedClass) - || self.settings.rules.enabled(Rule::PublicInit) + let enforce_docstrings = self.settings.rules.enabled(Rule::UndocumentedPublicModule) + || self.settings.rules.enabled(Rule::UndocumentedPublicClass) + || self.settings.rules.enabled(Rule::UndocumentedPublicMethod) + || self + .settings + .rules + .enabled(Rule::UndocumentedPublicFunction) + || self.settings.rules.enabled(Rule::UndocumentedPublicPackage) + || self.settings.rules.enabled(Rule::UndocumentedMagicMethod) + || self + .settings + .rules + .enabled(Rule::UndocumentedPublicNestedClass) + || self.settings.rules.enabled(Rule::UndocumentedPublicInit) || self.settings.rules.enabled(Rule::FitsOnOneLine) || self.settings.rules.enabled(Rule::NoBlankLineBeforeFunction) || self.settings.rules.enabled(Rule::NoBlankLineAfterFunction) @@ -5059,11 +5138,11 @@ impl<'a> Checker<'a> { || self.settings.rules.enabled(Rule::OneBlankLineAfterClass) || self.settings.rules.enabled(Rule::BlankLineAfterSummary) || self.settings.rules.enabled(Rule::IndentWithSpaces) - || self.settings.rules.enabled(Rule::NoUnderIndentation) - || self.settings.rules.enabled(Rule::NoOverIndentation) + || self.settings.rules.enabled(Rule::UnderIndentation) + || self.settings.rules.enabled(Rule::OverIndentation) || self.settings.rules.enabled(Rule::NewLineAfterLastParagraph) - || self.settings.rules.enabled(Rule::NoSurroundingWhitespace) - || self.settings.rules.enabled(Rule::NoBlankLineBeforeClass) + || self.settings.rules.enabled(Rule::SurroundingWhitespace) + || self.settings.rules.enabled(Rule::BlankLineBeforeClass) || self.settings.rules.enabled(Rule::MultiLineSummaryFirstLine) || self .settings @@ -5092,12 +5171,12 @@ impl<'a> Checker<'a> { .settings .rules .enabled(Rule::SectionUnderlineMatchesSectionLength) - || self.settings.rules.enabled(Rule::BlankLineAfterSection) - || self.settings.rules.enabled(Rule::BlankLineBeforeSection) + || self.settings.rules.enabled(Rule::NoBlankLineAfterSection) + || self.settings.rules.enabled(Rule::NoBlankLineBeforeSection) || self .settings .rules - .enabled(Rule::NoBlankLinesBetweenHeaderAndContent) + .enabled(Rule::BlankLinesBetweenHeaderAndContent) || self.settings.rules.enabled(Rule::BlankLineAfterLastSection) || self.settings.rules.enabled(Rule::EmptyDocstringSection) || self.settings.rules.enabled(Rule::EndsInPunctuation) @@ -5189,7 +5268,7 @@ impl<'a> Checker<'a> { } if self.settings.rules.enabled(Rule::OneBlankLineBeforeClass) || self.settings.rules.enabled(Rule::OneBlankLineAfterClass) - || self.settings.rules.enabled(Rule::NoBlankLineBeforeClass) + || self.settings.rules.enabled(Rule::BlankLineBeforeClass) { pydocstyle::rules::blank_before_after_class(self, &docstring); } @@ -5197,15 +5276,15 @@ impl<'a> Checker<'a> { pydocstyle::rules::blank_after_summary(self, &docstring); } if self.settings.rules.enabled(Rule::IndentWithSpaces) - || self.settings.rules.enabled(Rule::NoUnderIndentation) - || self.settings.rules.enabled(Rule::NoOverIndentation) + || self.settings.rules.enabled(Rule::UnderIndentation) + || self.settings.rules.enabled(Rule::OverIndentation) { pydocstyle::rules::indent(self, &docstring); } if self.settings.rules.enabled(Rule::NewLineAfterLastParagraph) { pydocstyle::rules::newline_after_last_paragraph(self, &docstring); } - if self.settings.rules.enabled(Rule::NoSurroundingWhitespace) { + if self.settings.rules.enabled(Rule::SurroundingWhitespace) { pydocstyle::rules::no_surrounding_whitespace(self, &docstring); } if self.settings.rules.enabled(Rule::MultiLineSummaryFirstLine) @@ -5264,12 +5343,12 @@ impl<'a> Checker<'a> { .settings .rules .enabled(Rule::SectionUnderlineMatchesSectionLength) - || self.settings.rules.enabled(Rule::BlankLineAfterSection) - || self.settings.rules.enabled(Rule::BlankLineBeforeSection) + || self.settings.rules.enabled(Rule::NoBlankLineAfterSection) + || self.settings.rules.enabled(Rule::NoBlankLineBeforeSection) || self .settings .rules - .enabled(Rule::NoBlankLinesBetweenHeaderAndContent) + .enabled(Rule::BlankLinesBetweenHeaderAndContent) || self.settings.rules.enabled(Rule::BlankLineAfterLastSection) || self.settings.rules.enabled(Rule::EmptyDocstringSection) || self.settings.rules.enabled(Rule::SectionNameEndsInColon) diff --git a/crates/ruff/src/checkers/physical_lines.rs b/crates/ruff/src/checkers/physical_lines.rs index cba4861f52..83f1a7778b 100644 --- a/crates/ruff/src/checkers/physical_lines.rs +++ b/crates/ruff/src/checkers/physical_lines.rs @@ -12,8 +12,8 @@ use crate::rules::flake8_executable::rules::{ shebang_missing, shebang_newline, shebang_not_executable, shebang_python, shebang_whitespace, }; use crate::rules::pycodestyle::rules::{ - doc_line_too_long, indentation_contains_tabs, line_too_long, mixed_spaces_and_tabs, - no_newline_at_end_of_file, trailing_whitespace, + doc_line_too_long, line_too_long, mixed_spaces_and_tabs, no_newline_at_end_of_file, + tab_indentation, trailing_whitespace, }; use crate::rules::pygrep_hooks::rules::{blanket_noqa, blanket_type_ignore}; use crate::rules::pylint; @@ -35,25 +35,25 @@ pub fn check_physical_lines( let enforce_blanket_noqa = settings.rules.enabled(Rule::BlanketNOQA); let enforce_shebang_not_executable = settings.rules.enabled(Rule::ShebangNotExecutable); let enforce_shebang_missing = settings.rules.enabled(Rule::ShebangMissingExecutableFile); - let enforce_shebang_whitespace = settings.rules.enabled(Rule::ShebangWhitespace); - let enforce_shebang_newline = settings.rules.enabled(Rule::ShebangNewline); - let enforce_shebang_python = settings.rules.enabled(Rule::ShebangPython); + let enforce_shebang_whitespace = settings.rules.enabled(Rule::ShebangLeadingWhitespace); + let enforce_shebang_newline = settings.rules.enabled(Rule::ShebangNotFirstLine); + let enforce_shebang_python = settings.rules.enabled(Rule::ShebangMissingPython); let enforce_blanket_type_ignore = settings.rules.enabled(Rule::BlanketTypeIgnore); let enforce_doc_line_too_long = settings.rules.enabled(Rule::DocLineTooLong); let enforce_line_too_long = settings.rules.enabled(Rule::LineTooLong); - let enforce_no_newline_at_end_of_file = settings.rules.enabled(Rule::NoNewLineAtEndOfFile); + let enforce_no_newline_at_end_of_file = settings.rules.enabled(Rule::MissingNewlineAtEndOfFile); let enforce_unnecessary_coding_comment = settings.rules.enabled(Rule::UTF8EncodingDeclaration); let enforce_mixed_spaces_and_tabs = settings.rules.enabled(Rule::MixedSpacesAndTabs); let enforce_bidirectional_unicode = settings.rules.enabled(Rule::BidirectionalUnicode); let enforce_trailing_whitespace = settings.rules.enabled(Rule::TrailingWhitespace); let enforce_blank_line_contains_whitespace = - settings.rules.enabled(Rule::BlankLineContainsWhitespace); - let enforce_indentation_contains_tabs = settings.rules.enabled(Rule::IndentationContainsTabs); + settings.rules.enabled(Rule::BlankLineWithWhitespace); + let enforce_tab_indentation = settings.rules.enabled(Rule::TabIndentation); let fix_unnecessary_coding_comment = autofix.into() && settings.rules.should_fix(Rule::UTF8EncodingDeclaration); let fix_shebang_whitespace = - autofix.into() && settings.rules.should_fix(Rule::ShebangWhitespace); + autofix.into() && settings.rules.should_fix(Rule::ShebangLeadingWhitespace); let mut commented_lines_iter = commented_lines.iter().peekable(); let mut doc_lines_iter = doc_lines.iter().peekable(); @@ -154,8 +154,8 @@ pub fn check_physical_lines( } } - if enforce_indentation_contains_tabs { - if let Some(diagnostic) = indentation_contains_tabs(index, line) { + if enforce_tab_indentation { + if let Some(diagnostic) = tab_indentation(index, line) { diagnostics.push(diagnostic); } } @@ -165,7 +165,7 @@ pub fn check_physical_lines( if let Some(diagnostic) = no_newline_at_end_of_file( locator, stylist, - autofix.into() && settings.rules.should_fix(Rule::NoNewLineAtEndOfFile), + autofix.into() && settings.rules.should_fix(Rule::MissingNewlineAtEndOfFile), ) { diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/checkers/tokens.rs b/crates/ruff/src/checkers/tokens.rs index df679a223f..8f337b471f 100644 --- a/crates/ruff/src/checkers/tokens.rs +++ b/crates/ruff/src/checkers/tokens.rs @@ -54,9 +54,9 @@ pub fn check_tokens( ]); let enforce_trailing_comma = settings.rules.any_enabled(&[ - Rule::TrailingCommaMissing, - Rule::TrailingCommaOnBareTupleProhibited, - Rule::TrailingCommaProhibited, + Rule::MissingTrailingComma, + Rule::TrailingCommaOnBareTuple, + Rule::ProhibitedTrailingComma, ]); let enforce_extraneous_parenthesis = settings.rules.enabled(Rule::ExtraneousParentheses); let enforce_type_comment_in_stub = settings.rules.enabled(Rule::TypeCommentInStub); diff --git a/crates/ruff/src/codes.rs b/crates/ruff/src/codes.rs index 41e618eddf..7fec6c8ecc 100644 --- a/crates/ruff/src/codes.rs +++ b/crates/ruff/src/codes.rs @@ -108,20 +108,20 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pycodestyle, "E999") => Rule::SyntaxError, // pycodestyle warnings - (Pycodestyle, "W191") => Rule::IndentationContainsTabs, + (Pycodestyle, "W191") => Rule::TabIndentation, (Pycodestyle, "W291") => Rule::TrailingWhitespace, - (Pycodestyle, "W292") => Rule::NoNewLineAtEndOfFile, - (Pycodestyle, "W293") => Rule::BlankLineContainsWhitespace, + (Pycodestyle, "W292") => Rule::MissingNewlineAtEndOfFile, + (Pycodestyle, "W293") => Rule::BlankLineWithWhitespace, (Pycodestyle, "W505") => Rule::DocLineTooLong, (Pycodestyle, "W605") => Rule::InvalidEscapeSequence, // pyflakes (Pyflakes, "401") => Rule::UnusedImport, (Pyflakes, "402") => Rule::ImportShadowedByLoopVar, - (Pyflakes, "403") => Rule::ImportStar, + (Pyflakes, "403") => Rule::UndefinedLocalWithImportStar, (Pyflakes, "404") => Rule::LateFutureImport, - (Pyflakes, "405") => Rule::ImportStarUsage, - (Pyflakes, "406") => Rule::ImportStarNotPermitted, + (Pyflakes, "405") => Rule::UndefinedLocalWithImportStarUsage, + (Pyflakes, "406") => Rule::UndefinedLocalWithNestedImportStarUsage, (Pyflakes, "407") => Rule::FutureFeatureNotDefined, (Pyflakes, "501") => Rule::PercentFormatInvalidFormat, (Pyflakes, "502") => Rule::PercentFormatExpectedMapping, @@ -141,7 +141,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pyflakes, "601") => Rule::MultiValueRepeatedKeyLiteral, (Pyflakes, "602") => Rule::MultiValueRepeatedKeyVariable, (Pyflakes, "621") => Rule::ExpressionsInStarAssignment, - (Pyflakes, "622") => Rule::TwoStarredExpressions, + (Pyflakes, "622") => Rule::MultipleStarredExpressions, (Pyflakes, "631") => Rule::AssertTuple, (Pyflakes, "632") => Rule::IsLiteral, (Pyflakes, "633") => Rule::InvalidPrintSyntax, @@ -168,7 +168,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pylint, "E0101") => Rule::ReturnInInit, (Pylint, "E0116") => Rule::ContinueInFinally, (Pylint, "E0117") => Rule::NonlocalWithoutBinding, - (Pylint, "E0118") => Rule::UsedPriorGlobalDeclaration, + (Pylint, "E0118") => Rule::UsePriorToGlobalDeclaration, (Pylint, "E0604") => Rule::InvalidAllObject, (Pylint, "E0605") => Rule::InvalidAllFormat, (Pylint, "E1142") => Rule::AwaitOutsideAsync, @@ -185,14 +185,14 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pylint, "E2515") => Rule::InvalidCharacterZeroWidthSpace, (Pylint, "R0133") => Rule::ComparisonOfConstant, (Pylint, "R0206") => Rule::PropertyWithParameters, - (Pylint, "R0402") => Rule::ConsiderUsingFromImport, + (Pylint, "R0402") => Rule::ManualFromImport, (Pylint, "R0911") => Rule::TooManyReturnStatements, (Pylint, "R0912") => Rule::TooManyBranches, (Pylint, "R0913") => Rule::TooManyArguments, (Pylint, "R0915") => Rule::TooManyStatements, - (Pylint, "R1701") => Rule::ConsiderMergingIsinstance, + (Pylint, "R1701") => Rule::RepeatedIsinstanceCalls, (Pylint, "R1711") => Rule::UselessReturn, - (Pylint, "R1722") => Rule::ConsiderUsingSysExit, + (Pylint, "R1722") => Rule::SysExitAlias, (Pylint, "R2004") => Rule::MagicValueComparison, (Pylint, "R5501") => Rule::CollapsibleElseIf, (Pylint, "W0120") => Rule::UselessElseOnLoop, @@ -213,7 +213,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8Bugbear, "005") => Rule::StripWithMultiCharacters, (Flake8Bugbear, "006") => Rule::MutableArgumentDefault, (Flake8Bugbear, "007") => Rule::UnusedLoopControlVariable, - (Flake8Bugbear, "008") => Rule::FunctionCallArgumentDefault, + (Flake8Bugbear, "008") => Rule::FunctionCallInDefaultArgument, (Flake8Bugbear, "009") => Rule::GetAttrWithConstant, (Flake8Bugbear, "010") => Rule::SetAttrWithConstant, (Flake8Bugbear, "011") => Rule::AssertFalse, @@ -287,8 +287,8 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8ImplicitStrConcat, "003") => Rule::ExplicitStringConcatenation, // flake8-print - (Flake8Print, "1") => Rule::PrintFound, - (Flake8Print, "3") => Rule::PPrintFound, + (Flake8Print, "1") => Rule::Print, + (Flake8Print, "3") => Rule::PPrint, // flake8-quotes (Flake8Quotes, "000") => Rule::BadQuotesInlineString, @@ -302,7 +302,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8Annotations, "003") => Rule::MissingTypeKwargs, (Flake8Annotations, "101") => Rule::MissingTypeSelf, (Flake8Annotations, "102") => Rule::MissingTypeCls, - (Flake8Annotations, "201") => Rule::MissingReturnTypePublicFunction, + (Flake8Annotations, "201") => Rule::MissingReturnTypeUndocumentedPublicFunction, (Flake8Annotations, "202") => Rule::MissingReturnTypePrivateFunction, (Flake8Annotations, "204") => Rule::MissingReturnTypeSpecialMethod, (Flake8Annotations, "205") => Rule::MissingReturnTypeStaticMethod, @@ -310,16 +310,16 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8Annotations, "401") => Rule::AnyType, // flake8-2020 - (Flake82020, "101") => Rule::SysVersionSlice3Referenced, - (Flake82020, "102") => Rule::SysVersion2Referenced, + (Flake82020, "101") => Rule::SysVersionSlice3, + (Flake82020, "102") => Rule::SysVersion2, (Flake82020, "103") => Rule::SysVersionCmpStr3, - (Flake82020, "201") => Rule::SysVersionInfo0Eq3Referenced, - (Flake82020, "202") => Rule::SixPY3Referenced, + (Flake82020, "201") => Rule::SysVersionInfo0Eq3, + (Flake82020, "202") => Rule::SixPY3, (Flake82020, "203") => Rule::SysVersionInfo1CmpInt, (Flake82020, "204") => Rule::SysVersionInfoMinorCmpInt, - (Flake82020, "301") => Rule::SysVersion0Referenced, + (Flake82020, "301") => Rule::SysVersion0, (Flake82020, "302") => Rule::SysVersionCmpStr10, - (Flake82020, "303") => Rule::SysVersionSlice1Referenced, + (Flake82020, "303") => Rule::SysVersionSlice1, // flake8-simplify (Flake8Simplify, "101") => Rule::DuplicateIsinstanceCall, @@ -327,16 +327,15 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8Simplify, "103") => Rule::NeedlessBool, (Flake8Simplify, "105") => Rule::UseContextlibSuppress, (Flake8Simplify, "107") => Rule::ReturnInTryExceptFinally, - (Flake8Simplify, "108") => Rule::UseTernaryOperator, + (Flake8Simplify, "108") => Rule::IfElseBlockInsteadOfIfExp, (Flake8Simplify, "109") => Rule::CompareWithTuple, (Flake8Simplify, "110") => Rule::ReimplementedBuiltin, - // (Flake8Simplify, "111") => Rule::ReimplementedBuiltin, - (Flake8Simplify, "112") => Rule::UseCapitalEnvironmentVariables, + (Flake8Simplify, "112") => Rule::UncapitalizedEnvironmentVariables, (Flake8Simplify, "114") => Rule::IfWithSameArms, (Flake8Simplify, "115") => Rule::OpenFileWithContextHandler, - (Flake8Simplify, "116") => Rule::ManualDictLookup, + (Flake8Simplify, "116") => Rule::IfElseBlockInsteadOfDictLookup, (Flake8Simplify, "117") => Rule::MultipleWithStatements, - (Flake8Simplify, "118") => Rule::KeyInDict, + (Flake8Simplify, "118") => Rule::InDictKeys, (Flake8Simplify, "201") => Rule::NegateEqualOp, (Flake8Simplify, "202") => Rule::NegateNotEqualOp, (Flake8Simplify, "208") => Rule::DoubleNegation, @@ -348,7 +347,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8Simplify, "222") => Rule::ExprOrTrue, (Flake8Simplify, "223") => Rule::ExprAndFalse, (Flake8Simplify, "300") => Rule::YodaConditions, - (Flake8Simplify, "401") => Rule::DictGetWithDefault, + (Flake8Simplify, "401") => Rule::IfElseBlockInsteadOfDictGet, // pyupgrade (Pyupgrade, "001") => Rule::UselessMetaclassType, @@ -371,17 +370,17 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pyupgrade, "020") => Rule::OpenAlias, (Pyupgrade, "021") => Rule::ReplaceUniversalNewlines, (Pyupgrade, "022") => Rule::ReplaceStdoutStderr, - (Pyupgrade, "023") => Rule::RewriteCElementTree, + (Pyupgrade, "023") => Rule::DeprecatedCElementTree, (Pyupgrade, "024") => Rule::OSErrorAlias, - (Pyupgrade, "025") => Rule::RewriteUnicodeLiteral, - (Pyupgrade, "026") => Rule::RewriteMockImport, - (Pyupgrade, "027") => Rule::RewriteListComprehension, - (Pyupgrade, "028") => Rule::RewriteYieldFrom, + (Pyupgrade, "025") => Rule::UnicodeKindPrefix, + (Pyupgrade, "026") => Rule::DeprecatedMockImport, + (Pyupgrade, "027") => Rule::UnpackedListComprehension, + (Pyupgrade, "028") => Rule::YieldInForLoop, (Pyupgrade, "029") => Rule::UnnecessaryBuiltinImport, (Pyupgrade, "030") => Rule::FormatLiterals, (Pyupgrade, "031") => Rule::PrintfStringFormatting, (Pyupgrade, "032") => Rule::FString, - (Pyupgrade, "033") => Rule::FunctoolsCache, + (Pyupgrade, "033") => Rule::LRUCacheWithMaxsizeNone, (Pyupgrade, "034") => Rule::ExtraneousParentheses, (Pyupgrade, "035") => Rule::DeprecatedImport, (Pyupgrade, "036") => Rule::OutdatedVersionBlock, @@ -389,14 +388,14 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pyupgrade, "038") => Rule::IsinstanceWithTuple, // pydocstyle - (Pydocstyle, "100") => Rule::PublicModule, - (Pydocstyle, "101") => Rule::PublicClass, - (Pydocstyle, "102") => Rule::PublicMethod, - (Pydocstyle, "103") => Rule::PublicFunction, - (Pydocstyle, "104") => Rule::PublicPackage, - (Pydocstyle, "105") => Rule::MagicMethod, - (Pydocstyle, "106") => Rule::PublicNestedClass, - (Pydocstyle, "107") => Rule::PublicInit, + (Pydocstyle, "100") => Rule::UndocumentedPublicModule, + (Pydocstyle, "101") => Rule::UndocumentedPublicClass, + (Pydocstyle, "102") => Rule::UndocumentedPublicMethod, + (Pydocstyle, "103") => Rule::UndocumentedPublicFunction, + (Pydocstyle, "104") => Rule::UndocumentedPublicPackage, + (Pydocstyle, "105") => Rule::UndocumentedMagicMethod, + (Pydocstyle, "106") => Rule::UndocumentedPublicNestedClass, + (Pydocstyle, "107") => Rule::UndocumentedPublicInit, (Pydocstyle, "200") => Rule::FitsOnOneLine, (Pydocstyle, "201") => Rule::NoBlankLineBeforeFunction, (Pydocstyle, "202") => Rule::NoBlankLineAfterFunction, @@ -404,11 +403,11 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pydocstyle, "204") => Rule::OneBlankLineAfterClass, (Pydocstyle, "205") => Rule::BlankLineAfterSummary, (Pydocstyle, "206") => Rule::IndentWithSpaces, - (Pydocstyle, "207") => Rule::NoUnderIndentation, - (Pydocstyle, "208") => Rule::NoOverIndentation, + (Pydocstyle, "207") => Rule::UnderIndentation, + (Pydocstyle, "208") => Rule::OverIndentation, (Pydocstyle, "209") => Rule::NewLineAfterLastParagraph, - (Pydocstyle, "210") => Rule::NoSurroundingWhitespace, - (Pydocstyle, "211") => Rule::NoBlankLineBeforeClass, + (Pydocstyle, "210") => Rule::SurroundingWhitespace, + (Pydocstyle, "211") => Rule::BlankLineBeforeClass, (Pydocstyle, "212") => Rule::MultiLineSummaryFirstLine, (Pydocstyle, "213") => Rule::MultiLineSummarySecondLine, (Pydocstyle, "214") => Rule::SectionNotOverIndented, @@ -425,9 +424,9 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Pydocstyle, "407") => Rule::DashedUnderlineAfterSection, (Pydocstyle, "408") => Rule::SectionUnderlineAfterName, (Pydocstyle, "409") => Rule::SectionUnderlineMatchesSectionLength, - (Pydocstyle, "410") => Rule::BlankLineAfterSection, - (Pydocstyle, "411") => Rule::BlankLineBeforeSection, - (Pydocstyle, "412") => Rule::NoBlankLinesBetweenHeaderAndContent, + (Pydocstyle, "410") => Rule::NoBlankLineAfterSection, + (Pydocstyle, "411") => Rule::NoBlankLineBeforeSection, + (Pydocstyle, "412") => Rule::BlankLinesBetweenHeaderAndContent, (Pydocstyle, "413") => Rule::BlankLineAfterLastSection, (Pydocstyle, "414") => Rule::EmptyDocstringSection, (Pydocstyle, "415") => Rule::EndsInPunctuation, @@ -509,24 +508,24 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8Datetimez, "012") => Rule::CallDateFromtimestamp, // pygrep-hooks - (PygrepHooks, "001") => Rule::NoEval, + (PygrepHooks, "001") => Rule::Eval, (PygrepHooks, "002") => Rule::DeprecatedLogWarn, (PygrepHooks, "003") => Rule::BlanketTypeIgnore, (PygrepHooks, "004") => Rule::BlanketNOQA, // pandas-vet - (PandasVet, "002") => Rule::UseOfInplaceArgument, - (PandasVet, "003") => Rule::UseOfDotIsNull, - (PandasVet, "004") => Rule::UseOfDotNotNull, - (PandasVet, "007") => Rule::UseOfDotIx, - (PandasVet, "008") => Rule::UseOfDotAt, - (PandasVet, "009") => Rule::UseOfDotIat, - (PandasVet, "010") => Rule::UseOfDotPivotOrUnstack, - (PandasVet, "011") => Rule::UseOfDotValues, - (PandasVet, "012") => Rule::UseOfDotReadTable, - (PandasVet, "013") => Rule::UseOfDotStack, - (PandasVet, "015") => Rule::UseOfPdMerge, - (PandasVet, "901") => Rule::DfIsABadVariableName, + (PandasVet, "002") => Rule::PandasUseOfInplaceArgument, + (PandasVet, "003") => Rule::PandasUseOfDotIsNull, + (PandasVet, "004") => Rule::PandasUseOfDotNotNull, + (PandasVet, "007") => Rule::PandasUseOfDotIx, + (PandasVet, "008") => Rule::PandasUseOfDotAt, + (PandasVet, "009") => Rule::PandasUseOfDotIat, + (PandasVet, "010") => Rule::PandasUseOfDotPivotOrUnstack, + (PandasVet, "011") => Rule::PandasUseOfDotValues, + (PandasVet, "012") => Rule::PandasUseOfDotReadTable, + (PandasVet, "013") => Rule::PandasUseOfDotStack, + (PandasVet, "015") => Rule::PandasUseOfPdMerge, + (PandasVet, "901") => Rule::PandasDfVariableName, // flake8-errmsg (Flake8ErrMsg, "101") => Rule::RawStringInException, @@ -534,58 +533,58 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Flake8ErrMsg, "103") => Rule::DotFormatInException, // flake8-pyi - (Flake8Pyi, "001") => Rule::PrefixTypeParams, + (Flake8Pyi, "001") => Rule::UnprefixedTypeParam, (Flake8Pyi, "006") => Rule::BadVersionInfoComparison, (Flake8Pyi, "007") => Rule::UnrecognizedPlatformCheck, (Flake8Pyi, "008") => Rule::UnrecognizedPlatformName, (Flake8Pyi, "009") => Rule::PassStatementStubBody, (Flake8Pyi, "010") => Rule::NonEmptyStubBody, - (Flake8Pyi, "011") => Rule::TypedArgumentSimpleDefaults, - (Flake8Pyi, "014") => Rule::ArgumentSimpleDefaults, + (Flake8Pyi, "011") => Rule::TypedArgumentDefaultInStub, + (Flake8Pyi, "014") => Rule::ArgumentDefaultInStub, (Flake8Pyi, "021") => Rule::DocstringInStub, (Flake8Pyi, "033") => Rule::TypeCommentInStub, // flake8-pytest-style - (Flake8PytestStyle, "001") => Rule::IncorrectFixtureParenthesesStyle, - (Flake8PytestStyle, "002") => Rule::FixturePositionalArgs, - (Flake8PytestStyle, "003") => Rule::ExtraneousScopeFunction, - (Flake8PytestStyle, "004") => Rule::MissingFixtureNameUnderscore, - (Flake8PytestStyle, "005") => Rule::IncorrectFixtureNameUnderscore, - (Flake8PytestStyle, "006") => Rule::ParametrizeNamesWrongType, - (Flake8PytestStyle, "007") => Rule::ParametrizeValuesWrongType, - (Flake8PytestStyle, "008") => Rule::PatchWithLambda, - (Flake8PytestStyle, "009") => Rule::UnittestAssertion, - (Flake8PytestStyle, "010") => Rule::RaisesWithoutException, - (Flake8PytestStyle, "011") => Rule::RaisesTooBroad, - (Flake8PytestStyle, "012") => Rule::RaisesWithMultipleStatements, - (Flake8PytestStyle, "013") => Rule::IncorrectPytestImport, - (Flake8PytestStyle, "015") => Rule::AssertAlwaysFalse, - (Flake8PytestStyle, "016") => Rule::FailWithoutMessage, - (Flake8PytestStyle, "017") => Rule::AssertInExcept, - (Flake8PytestStyle, "018") => Rule::CompositeAssertion, - (Flake8PytestStyle, "019") => Rule::FixtureParamWithoutValue, - (Flake8PytestStyle, "020") => Rule::DeprecatedYieldFixture, - (Flake8PytestStyle, "021") => Rule::FixtureFinalizerCallback, - (Flake8PytestStyle, "022") => Rule::UselessYieldFixture, - (Flake8PytestStyle, "023") => Rule::IncorrectMarkParenthesesStyle, - (Flake8PytestStyle, "024") => Rule::UnnecessaryAsyncioMarkOnFixture, - (Flake8PytestStyle, "025") => Rule::ErroneousUseFixturesOnFixture, - (Flake8PytestStyle, "026") => Rule::UseFixturesWithoutParameters, + (Flake8PytestStyle, "001") => Rule::PytestFixtureIncorrectParenthesesStyle, + (Flake8PytestStyle, "002") => Rule::PytestFixturePositionalArgs, + (Flake8PytestStyle, "003") => Rule::PytestExtraneousScopeFunction, + (Flake8PytestStyle, "004") => Rule::PytestMissingFixtureNameUnderscore, + (Flake8PytestStyle, "005") => Rule::PytestIncorrectFixtureNameUnderscore, + (Flake8PytestStyle, "006") => Rule::PytestParametrizeNamesWrongType, + (Flake8PytestStyle, "007") => Rule::PytestParametrizeValuesWrongType, + (Flake8PytestStyle, "008") => Rule::PytestPatchWithLambda, + (Flake8PytestStyle, "009") => Rule::PytestUnittestAssertion, + (Flake8PytestStyle, "010") => Rule::PytestRaisesWithoutException, + (Flake8PytestStyle, "011") => Rule::PytestRaisesTooBroad, + (Flake8PytestStyle, "012") => Rule::PytestRaisesWithMultipleStatements, + (Flake8PytestStyle, "013") => Rule::PytestIncorrectPytestImport, + (Flake8PytestStyle, "015") => Rule::PytestAssertAlwaysFalse, + (Flake8PytestStyle, "016") => Rule::PytestFailWithoutMessage, + (Flake8PytestStyle, "017") => Rule::PytestAssertInExcept, + (Flake8PytestStyle, "018") => Rule::PytestCompositeAssertion, + (Flake8PytestStyle, "019") => Rule::PytestFixtureParamWithoutValue, + (Flake8PytestStyle, "020") => Rule::PytestDeprecatedYieldFixture, + (Flake8PytestStyle, "021") => Rule::PytestFixtureFinalizerCallback, + (Flake8PytestStyle, "022") => Rule::PytestUselessYieldFixture, + (Flake8PytestStyle, "023") => Rule::PytestIncorrectMarkParenthesesStyle, + (Flake8PytestStyle, "024") => Rule::PytestUnnecessaryAsyncioMarkOnFixture, + (Flake8PytestStyle, "025") => Rule::PytestErroneousUseFixturesOnFixture, + (Flake8PytestStyle, "026") => Rule::PytestUseFixturesWithoutParameters, // flake8-pie (Flake8Pie, "790") => Rule::UnnecessaryPass, - (Flake8Pie, "794") => Rule::DupeClassFieldDefinitions, - (Flake8Pie, "796") => Rule::PreferUniqueEnums, + (Flake8Pie, "794") => Rule::DuplicateClassFieldDefinition, + (Flake8Pie, "796") => Rule::NonUniqueEnums, (Flake8Pie, "800") => Rule::UnnecessarySpread, (Flake8Pie, "802") => Rule::UnnecessaryComprehensionAnyAll, (Flake8Pie, "804") => Rule::UnnecessaryDictKwargs, - (Flake8Pie, "807") => Rule::PreferListBuiltin, - (Flake8Pie, "810") => Rule::SingleStartsEndsWith, + (Flake8Pie, "807") => Rule::ReimplementedListBuiltin, + (Flake8Pie, "810") => Rule::MultipleStartsEndsWith, // flake8-commas - (Flake8Commas, "812") => Rule::TrailingCommaMissing, - (Flake8Commas, "818") => Rule::TrailingCommaOnBareTupleProhibited, - (Flake8Commas, "819") => Rule::TrailingCommaProhibited, + (Flake8Commas, "812") => Rule::MissingTrailingComma, + (Flake8Commas, "818") => Rule::TrailingCommaOnBareTuple, + (Flake8Commas, "819") => Rule::ProhibitedTrailingComma, // flake8-no-pep420 (Flake8NoPep420, "001") => Rule::ImplicitNamespacePackage, @@ -593,9 +592,9 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { // flake8-executable (Flake8Executable, "001") => Rule::ShebangNotExecutable, (Flake8Executable, "002") => Rule::ShebangMissingExecutableFile, - (Flake8Executable, "003") => Rule::ShebangPython, - (Flake8Executable, "004") => Rule::ShebangWhitespace, - (Flake8Executable, "005") => Rule::ShebangNewline, + (Flake8Executable, "003") => Rule::ShebangMissingPython, + (Flake8Executable, "004") => Rule::ShebangLeadingWhitespace, + (Flake8Executable, "005") => Rule::ShebangNotFirstLine, // flake8-type-checking (Flake8TypeChecking, "001") => Rule::TypingOnlyFirstPartyImport, @@ -607,7 +606,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { // tryceratops (Tryceratops, "002") => Rule::RaiseVanillaClass, (Tryceratops, "003") => Rule::RaiseVanillaArgs, - (Tryceratops, "004") => Rule::PreferTypeError, + (Tryceratops, "004") => Rule::TypeCheckWithoutTypeError, (Tryceratops, "200") => Rule::ReraiseNoCause, (Tryceratops, "201") => Rule::VerboseRaise, (Tryceratops, "300") => Rule::TryConsiderElse, @@ -666,18 +665,18 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option { (Ruff, "001") => Rule::AmbiguousUnicodeCharacterString, (Ruff, "002") => Rule::AmbiguousUnicodeCharacterDocstring, (Ruff, "003") => Rule::AmbiguousUnicodeCharacterComment, - (Ruff, "005") => Rule::UnpackInsteadOfConcatenatingToCollectionLiteral, + (Ruff, "005") => Rule::CollectionLiteralConcatenation, (Ruff, "006") => Rule::AsyncioDanglingTask, (Ruff, "007") => Rule::PairwiseOverZipped, (Ruff, "100") => Rule::UnusedNOQA, // flake8-django - (Flake8Django, "001") => Rule::NullableModelStringField, - (Flake8Django, "003") => Rule::LocalsInRenderFunction, - (Flake8Django, "006") => Rule::ExcludeWithModelForm, - (Flake8Django, "007") => Rule::AllWithModelForm, - (Flake8Django, "008") => Rule::ModelWithoutDunderStr, - (Flake8Django, "013") => Rule::NonLeadingReceiverDecorator, + (Flake8Django, "001") => Rule::DjangoNullableModelStringField, + (Flake8Django, "003") => Rule::DjangoLocalsInRenderFunction, + (Flake8Django, "006") => Rule::DjangoExcludeWithModelForm, + (Flake8Django, "007") => Rule::DjangoAllWithModelForm, + (Flake8Django, "008") => Rule::DjangoModelWithoutDunderStr, + (Flake8Django, "013") => Rule::DjangoNonLeadingReceiverDecorator, _ => return None, }) diff --git a/crates/ruff/src/registry.rs b/crates/ruff/src/registry.rs index fdd1188959..6d1db2bbc2 100644 --- a/crates/ruff/src/registry.rs +++ b/crates/ruff/src/registry.rs @@ -92,19 +92,19 @@ ruff_macros::register_rules!( rules::pycodestyle::rules::IOError, rules::pycodestyle::rules::SyntaxError, // pycodestyle warnings - rules::pycodestyle::rules::IndentationContainsTabs, + rules::pycodestyle::rules::TabIndentation, rules::pycodestyle::rules::TrailingWhitespace, - rules::pycodestyle::rules::NoNewLineAtEndOfFile, - rules::pycodestyle::rules::BlankLineContainsWhitespace, + rules::pycodestyle::rules::MissingNewlineAtEndOfFile, + rules::pycodestyle::rules::BlankLineWithWhitespace, rules::pycodestyle::rules::DocLineTooLong, rules::pycodestyle::rules::InvalidEscapeSequence, // pyflakes rules::pyflakes::rules::UnusedImport, rules::pyflakes::rules::ImportShadowedByLoopVar, - rules::pyflakes::rules::ImportStar, + rules::pyflakes::rules::UndefinedLocalWithImportStar, rules::pyflakes::rules::LateFutureImport, - rules::pyflakes::rules::ImportStarUsage, - rules::pyflakes::rules::ImportStarNotPermitted, + rules::pyflakes::rules::UndefinedLocalWithImportStarUsage, + rules::pyflakes::rules::UndefinedLocalWithNestedImportStarUsage, rules::pyflakes::rules::FutureFeatureNotDefined, rules::pyflakes::rules::PercentFormatInvalidFormat, rules::pyflakes::rules::PercentFormatExpectedMapping, @@ -124,7 +124,7 @@ ruff_macros::register_rules!( rules::pyflakes::rules::MultiValueRepeatedKeyLiteral, rules::pyflakes::rules::MultiValueRepeatedKeyVariable, rules::pyflakes::rules::ExpressionsInStarAssignment, - rules::pyflakes::rules::TwoStarredExpressions, + rules::pyflakes::rules::MultipleStarredExpressions, rules::pyflakes::rules::AssertTuple, rules::pyflakes::rules::IsLiteral, rules::pyflakes::rules::InvalidPrintSyntax, @@ -162,15 +162,15 @@ ruff_macros::register_rules!( rules::pylint::rules::UselessImportAlias, rules::pylint::rules::UnnecessaryDirectLambdaCall, rules::pylint::rules::NonlocalWithoutBinding, - rules::pylint::rules::UsedPriorGlobalDeclaration, + rules::pylint::rules::UsePriorToGlobalDeclaration, rules::pylint::rules::AwaitOutsideAsync, rules::pylint::rules::PropertyWithParameters, rules::pylint::rules::ReturnInInit, - rules::pylint::rules::ConsiderUsingFromImport, + rules::pylint::rules::ManualFromImport, rules::pylint::rules::CompareToEmptyString, rules::pylint::rules::ComparisonOfConstant, - rules::pylint::rules::ConsiderMergingIsinstance, - rules::pylint::rules::ConsiderUsingSysExit, + rules::pylint::rules::RepeatedIsinstanceCalls, + rules::pylint::rules::SysExitAlias, rules::pylint::rules::MagicValueComparison, rules::pylint::rules::UselessElseOnLoop, rules::pylint::rules::GlobalStatement, @@ -194,7 +194,7 @@ ruff_macros::register_rules!( rules::flake8_bugbear::rules::MutableArgumentDefault, rules::flake8_bugbear::rules::NoExplicitStacklevel, rules::flake8_bugbear::rules::UnusedLoopControlVariable, - rules::flake8_bugbear::rules::FunctionCallArgumentDefault, + rules::flake8_bugbear::rules::FunctionCallInDefaultArgument, rules::flake8_bugbear::rules::GetAttrWithConstant, rules::flake8_bugbear::rules::SetAttrWithConstant, rules::flake8_bugbear::rules::AssertFalse, @@ -259,8 +259,8 @@ ruff_macros::register_rules!( rules::flake8_implicit_str_concat::rules::MultiLineImplicitStringConcatenation, rules::flake8_implicit_str_concat::rules::ExplicitStringConcatenation, // flake8-print - rules::flake8_print::rules::PrintFound, - rules::flake8_print::rules::PPrintFound, + rules::flake8_print::rules::Print, + rules::flake8_print::rules::PPrint, // flake8-quotes rules::flake8_quotes::rules::BadQuotesInlineString, rules::flake8_quotes::rules::BadQuotesMultilineString, @@ -272,38 +272,38 @@ ruff_macros::register_rules!( rules::flake8_annotations::rules::MissingTypeKwargs, rules::flake8_annotations::rules::MissingTypeSelf, rules::flake8_annotations::rules::MissingTypeCls, - rules::flake8_annotations::rules::MissingReturnTypePublicFunction, + rules::flake8_annotations::rules::MissingReturnTypeUndocumentedPublicFunction, rules::flake8_annotations::rules::MissingReturnTypePrivateFunction, rules::flake8_annotations::rules::MissingReturnTypeSpecialMethod, rules::flake8_annotations::rules::MissingReturnTypeStaticMethod, rules::flake8_annotations::rules::MissingReturnTypeClassMethod, rules::flake8_annotations::rules::AnyType, // flake8-2020 - rules::flake8_2020::rules::SysVersionSlice3Referenced, - rules::flake8_2020::rules::SysVersion2Referenced, + rules::flake8_2020::rules::SysVersionSlice3, + rules::flake8_2020::rules::SysVersion2, rules::flake8_2020::rules::SysVersionCmpStr3, - rules::flake8_2020::rules::SysVersionInfo0Eq3Referenced, - rules::flake8_2020::rules::SixPY3Referenced, + rules::flake8_2020::rules::SysVersionInfo0Eq3, + rules::flake8_2020::rules::SixPY3, rules::flake8_2020::rules::SysVersionInfo1CmpInt, rules::flake8_2020::rules::SysVersionInfoMinorCmpInt, - rules::flake8_2020::rules::SysVersion0Referenced, + rules::flake8_2020::rules::SysVersion0, rules::flake8_2020::rules::SysVersionCmpStr10, - rules::flake8_2020::rules::SysVersionSlice1Referenced, + rules::flake8_2020::rules::SysVersionSlice1, // flake8-simplify - rules::flake8_simplify::rules::ManualDictLookup, + rules::flake8_simplify::rules::IfElseBlockInsteadOfDictLookup, rules::flake8_simplify::rules::DuplicateIsinstanceCall, rules::flake8_simplify::rules::CollapsibleIf, rules::flake8_simplify::rules::NeedlessBool, rules::flake8_simplify::rules::UseContextlibSuppress, rules::flake8_simplify::rules::ReturnInTryExceptFinally, - rules::flake8_simplify::rules::UseTernaryOperator, + rules::flake8_simplify::rules::IfElseBlockInsteadOfIfExp, rules::flake8_simplify::rules::CompareWithTuple, rules::flake8_simplify::rules::ReimplementedBuiltin, - rules::flake8_simplify::rules::UseCapitalEnvironmentVariables, + rules::flake8_simplify::rules::UncapitalizedEnvironmentVariables, rules::flake8_simplify::rules::IfWithSameArms, rules::flake8_simplify::rules::OpenFileWithContextHandler, rules::flake8_simplify::rules::MultipleWithStatements, - rules::flake8_simplify::rules::KeyInDict, + rules::flake8_simplify::rules::InDictKeys, rules::flake8_simplify::rules::NegateEqualOp, rules::flake8_simplify::rules::NegateNotEqualOp, rules::flake8_simplify::rules::DoubleNegation, @@ -315,7 +315,7 @@ ruff_macros::register_rules!( rules::flake8_simplify::rules::ExprOrTrue, rules::flake8_simplify::rules::ExprAndFalse, rules::flake8_simplify::rules::YodaConditions, - rules::flake8_simplify::rules::DictGetWithDefault, + rules::flake8_simplify::rules::IfElseBlockInsteadOfDictGet, // pyupgrade rules::pyupgrade::rules::UselessMetaclassType, rules::pyupgrade::rules::TypeOfPrimitive, @@ -337,31 +337,31 @@ ruff_macros::register_rules!( rules::pyupgrade::rules::OpenAlias, rules::pyupgrade::rules::ReplaceUniversalNewlines, rules::pyupgrade::rules::ReplaceStdoutStderr, - rules::pyupgrade::rules::RewriteCElementTree, + rules::pyupgrade::rules::DeprecatedCElementTree, rules::pyupgrade::rules::OSErrorAlias, - rules::pyupgrade::rules::RewriteUnicodeLiteral, - rules::pyupgrade::rules::RewriteMockImport, - rules::pyupgrade::rules::RewriteListComprehension, - rules::pyupgrade::rules::RewriteYieldFrom, + rules::pyupgrade::rules::UnicodeKindPrefix, + rules::pyupgrade::rules::DeprecatedMockImport, + rules::pyupgrade::rules::UnpackedListComprehension, + rules::pyupgrade::rules::YieldInForLoop, rules::pyupgrade::rules::UnnecessaryBuiltinImport, rules::pyupgrade::rules::FormatLiterals, rules::pyupgrade::rules::PrintfStringFormatting, rules::pyupgrade::rules::FString, - rules::pyupgrade::rules::FunctoolsCache, + rules::pyupgrade::rules::LRUCacheWithMaxsizeNone, rules::pyupgrade::rules::ExtraneousParentheses, rules::pyupgrade::rules::DeprecatedImport, rules::pyupgrade::rules::OutdatedVersionBlock, rules::pyupgrade::rules::QuotedAnnotation, rules::pyupgrade::rules::IsinstanceWithTuple, // pydocstyle - rules::pydocstyle::rules::PublicModule, - rules::pydocstyle::rules::PublicClass, - rules::pydocstyle::rules::PublicMethod, - rules::pydocstyle::rules::PublicFunction, - rules::pydocstyle::rules::PublicPackage, - rules::pydocstyle::rules::MagicMethod, - rules::pydocstyle::rules::PublicNestedClass, - rules::pydocstyle::rules::PublicInit, + rules::pydocstyle::rules::UndocumentedPublicModule, + rules::pydocstyle::rules::UndocumentedPublicClass, + rules::pydocstyle::rules::UndocumentedPublicMethod, + rules::pydocstyle::rules::UndocumentedPublicFunction, + rules::pydocstyle::rules::UndocumentedPublicPackage, + rules::pydocstyle::rules::UndocumentedMagicMethod, + rules::pydocstyle::rules::UndocumentedPublicNestedClass, + rules::pydocstyle::rules::UndocumentedPublicInit, rules::pydocstyle::rules::FitsOnOneLine, rules::pydocstyle::rules::NoBlankLineBeforeFunction, rules::pydocstyle::rules::NoBlankLineAfterFunction, @@ -369,11 +369,11 @@ ruff_macros::register_rules!( rules::pydocstyle::rules::OneBlankLineAfterClass, rules::pydocstyle::rules::BlankLineAfterSummary, rules::pydocstyle::rules::IndentWithSpaces, - rules::pydocstyle::rules::NoUnderIndentation, - rules::pydocstyle::rules::NoOverIndentation, + rules::pydocstyle::rules::UnderIndentation, + rules::pydocstyle::rules::OverIndentation, rules::pydocstyle::rules::NewLineAfterLastParagraph, - rules::pydocstyle::rules::NoSurroundingWhitespace, - rules::pydocstyle::rules::NoBlankLineBeforeClass, + rules::pydocstyle::rules::SurroundingWhitespace, + rules::pydocstyle::rules::BlankLineBeforeClass, rules::pydocstyle::rules::MultiLineSummaryFirstLine, rules::pydocstyle::rules::MultiLineSummarySecondLine, rules::pydocstyle::rules::SectionNotOverIndented, @@ -390,9 +390,9 @@ ruff_macros::register_rules!( rules::pydocstyle::rules::DashedUnderlineAfterSection, rules::pydocstyle::rules::SectionUnderlineAfterName, rules::pydocstyle::rules::SectionUnderlineMatchesSectionLength, - rules::pydocstyle::rules::BlankLineAfterSection, - rules::pydocstyle::rules::BlankLineBeforeSection, - rules::pydocstyle::rules::NoBlankLinesBetweenHeaderAndContent, + rules::pydocstyle::rules::NoBlankLineAfterSection, + rules::pydocstyle::rules::NoBlankLineBeforeSection, + rules::pydocstyle::rules::BlankLinesBetweenHeaderAndContent, rules::pydocstyle::rules::BlankLineAfterLastSection, rules::pydocstyle::rules::EmptyDocstringSection, rules::pydocstyle::rules::EndsInPunctuation, @@ -465,85 +465,85 @@ ruff_macros::register_rules!( rules::flake8_datetimez::rules::CallDateToday, rules::flake8_datetimez::rules::CallDateFromtimestamp, // pygrep-hooks - rules::pygrep_hooks::rules::NoEval, + rules::pygrep_hooks::rules::Eval, rules::pygrep_hooks::rules::DeprecatedLogWarn, rules::pygrep_hooks::rules::BlanketTypeIgnore, rules::pygrep_hooks::rules::BlanketNOQA, // pandas-vet - rules::pandas_vet::rules::UseOfInplaceArgument, - rules::pandas_vet::rules::UseOfDotIsNull, - rules::pandas_vet::rules::UseOfDotNotNull, - rules::pandas_vet::rules::UseOfDotIx, - rules::pandas_vet::rules::UseOfDotAt, - rules::pandas_vet::rules::UseOfDotIat, - rules::pandas_vet::rules::UseOfDotPivotOrUnstack, - rules::pandas_vet::rules::UseOfDotValues, - rules::pandas_vet::rules::UseOfDotReadTable, - rules::pandas_vet::rules::UseOfDotStack, - rules::pandas_vet::rules::UseOfPdMerge, - rules::pandas_vet::rules::DfIsABadVariableName, + rules::pandas_vet::rules::PandasUseOfInplaceArgument, + rules::pandas_vet::rules::PandasUseOfDotIsNull, + rules::pandas_vet::rules::PandasUseOfDotNotNull, + rules::pandas_vet::rules::PandasUseOfDotIx, + rules::pandas_vet::rules::PandasUseOfDotAt, + rules::pandas_vet::rules::PandasUseOfDotIat, + rules::pandas_vet::rules::PandasUseOfDotPivotOrUnstack, + rules::pandas_vet::rules::PandasUseOfDotValues, + rules::pandas_vet::rules::PandasUseOfDotReadTable, + rules::pandas_vet::rules::PandasUseOfDotStack, + rules::pandas_vet::rules::PandasUseOfPdMerge, + rules::pandas_vet::rules::PandasDfVariableName, // flake8-errmsg rules::flake8_errmsg::rules::RawStringInException, rules::flake8_errmsg::rules::FStringInException, rules::flake8_errmsg::rules::DotFormatInException, // flake8-pyi - rules::flake8_pyi::rules::PrefixTypeParams, + rules::flake8_pyi::rules::UnprefixedTypeParam, rules::flake8_pyi::rules::BadVersionInfoComparison, rules::flake8_pyi::rules::UnrecognizedPlatformCheck, rules::flake8_pyi::rules::UnrecognizedPlatformName, rules::flake8_pyi::rules::PassStatementStubBody, rules::flake8_pyi::rules::NonEmptyStubBody, rules::flake8_pyi::rules::DocstringInStub, - rules::flake8_pyi::rules::TypedArgumentSimpleDefaults, - rules::flake8_pyi::rules::ArgumentSimpleDefaults, + rules::flake8_pyi::rules::TypedArgumentDefaultInStub, + rules::flake8_pyi::rules::ArgumentDefaultInStub, rules::flake8_pyi::rules::TypeCommentInStub, // flake8-pytest-style - rules::flake8_pytest_style::rules::IncorrectFixtureParenthesesStyle, - rules::flake8_pytest_style::rules::FixturePositionalArgs, - rules::flake8_pytest_style::rules::ExtraneousScopeFunction, - rules::flake8_pytest_style::rules::MissingFixtureNameUnderscore, - rules::flake8_pytest_style::rules::IncorrectFixtureNameUnderscore, - rules::flake8_pytest_style::rules::ParametrizeNamesWrongType, - rules::flake8_pytest_style::rules::ParametrizeValuesWrongType, - rules::flake8_pytest_style::rules::PatchWithLambda, - rules::flake8_pytest_style::rules::UnittestAssertion, - rules::flake8_pytest_style::rules::RaisesWithoutException, - rules::flake8_pytest_style::rules::RaisesTooBroad, - rules::flake8_pytest_style::rules::RaisesWithMultipleStatements, - rules::flake8_pytest_style::rules::IncorrectPytestImport, - rules::flake8_pytest_style::rules::AssertAlwaysFalse, - rules::flake8_pytest_style::rules::FailWithoutMessage, - rules::flake8_pytest_style::rules::AssertInExcept, - rules::flake8_pytest_style::rules::CompositeAssertion, - rules::flake8_pytest_style::rules::FixtureParamWithoutValue, - rules::flake8_pytest_style::rules::DeprecatedYieldFixture, - rules::flake8_pytest_style::rules::FixtureFinalizerCallback, - rules::flake8_pytest_style::rules::UselessYieldFixture, - rules::flake8_pytest_style::rules::IncorrectMarkParenthesesStyle, - rules::flake8_pytest_style::rules::UnnecessaryAsyncioMarkOnFixture, - rules::flake8_pytest_style::rules::ErroneousUseFixturesOnFixture, - rules::flake8_pytest_style::rules::UseFixturesWithoutParameters, + rules::flake8_pytest_style::rules::PytestFixtureIncorrectParenthesesStyle, + rules::flake8_pytest_style::rules::PytestFixturePositionalArgs, + rules::flake8_pytest_style::rules::PytestExtraneousScopeFunction, + rules::flake8_pytest_style::rules::PytestMissingFixtureNameUnderscore, + rules::flake8_pytest_style::rules::PytestIncorrectFixtureNameUnderscore, + rules::flake8_pytest_style::rules::PytestParametrizeNamesWrongType, + rules::flake8_pytest_style::rules::PytestParametrizeValuesWrongType, + rules::flake8_pytest_style::rules::PytestPatchWithLambda, + rules::flake8_pytest_style::rules::PytestUnittestAssertion, + rules::flake8_pytest_style::rules::PytestRaisesWithoutException, + rules::flake8_pytest_style::rules::PytestRaisesTooBroad, + rules::flake8_pytest_style::rules::PytestRaisesWithMultipleStatements, + rules::flake8_pytest_style::rules::PytestIncorrectPytestImport, + rules::flake8_pytest_style::rules::PytestAssertAlwaysFalse, + rules::flake8_pytest_style::rules::PytestFailWithoutMessage, + rules::flake8_pytest_style::rules::PytestAssertInExcept, + rules::flake8_pytest_style::rules::PytestCompositeAssertion, + rules::flake8_pytest_style::rules::PytestFixtureParamWithoutValue, + rules::flake8_pytest_style::rules::PytestDeprecatedYieldFixture, + rules::flake8_pytest_style::rules::PytestFixtureFinalizerCallback, + rules::flake8_pytest_style::rules::PytestUselessYieldFixture, + rules::flake8_pytest_style::rules::PytestIncorrectMarkParenthesesStyle, + rules::flake8_pytest_style::rules::PytestUnnecessaryAsyncioMarkOnFixture, + rules::flake8_pytest_style::rules::PytestErroneousUseFixturesOnFixture, + rules::flake8_pytest_style::rules::PytestUseFixturesWithoutParameters, // flake8-pie rules::flake8_pie::rules::UnnecessaryPass, - rules::flake8_pie::rules::DupeClassFieldDefinitions, - rules::flake8_pie::rules::PreferUniqueEnums, + rules::flake8_pie::rules::DuplicateClassFieldDefinition, + rules::flake8_pie::rules::NonUniqueEnums, rules::flake8_pie::rules::UnnecessarySpread, rules::flake8_pie::rules::UnnecessaryDictKwargs, - rules::flake8_pie::rules::PreferListBuiltin, - rules::flake8_pie::rules::SingleStartsEndsWith, + rules::flake8_pie::rules::ReimplementedListBuiltin, + rules::flake8_pie::rules::MultipleStartsEndsWith, rules::flake8_pie::rules::UnnecessaryComprehensionAnyAll, // flake8-commas - rules::flake8_commas::rules::TrailingCommaMissing, - rules::flake8_commas::rules::TrailingCommaOnBareTupleProhibited, - rules::flake8_commas::rules::TrailingCommaProhibited, + rules::flake8_commas::rules::MissingTrailingComma, + rules::flake8_commas::rules::TrailingCommaOnBareTuple, + rules::flake8_commas::rules::ProhibitedTrailingComma, // flake8-no-pep420 rules::flake8_no_pep420::rules::ImplicitNamespacePackage, // flake8-executable rules::flake8_executable::rules::ShebangNotExecutable, rules::flake8_executable::rules::ShebangMissingExecutableFile, - rules::flake8_executable::rules::ShebangPython, - rules::flake8_executable::rules::ShebangWhitespace, - rules::flake8_executable::rules::ShebangNewline, + rules::flake8_executable::rules::ShebangMissingPython, + rules::flake8_executable::rules::ShebangLeadingWhitespace, + rules::flake8_executable::rules::ShebangNotFirstLine, // flake8-type-checking rules::flake8_type_checking::rules::TypingOnlyFirstPartyImport, rules::flake8_type_checking::rules::TypingOnlyThirdPartyImport, @@ -553,7 +553,7 @@ ruff_macros::register_rules!( // tryceratops rules::tryceratops::rules::RaiseVanillaClass, rules::tryceratops::rules::RaiseVanillaArgs, - rules::tryceratops::rules::PreferTypeError, + rules::tryceratops::rules::TypeCheckWithoutTypeError, rules::tryceratops::rules::ReraiseNoCause, rules::tryceratops::rules::VerboseRaise, rules::tryceratops::rules::TryConsiderElse, @@ -606,17 +606,17 @@ ruff_macros::register_rules!( rules::ruff::rules::AmbiguousUnicodeCharacterString, rules::ruff::rules::AmbiguousUnicodeCharacterDocstring, rules::ruff::rules::AmbiguousUnicodeCharacterComment, - rules::ruff::rules::UnpackInsteadOfConcatenatingToCollectionLiteral, + rules::ruff::rules::CollectionLiteralConcatenation, rules::ruff::rules::AsyncioDanglingTask, rules::ruff::rules::UnusedNOQA, rules::ruff::rules::PairwiseOverZipped, // flake8-django - rules::flake8_django::rules::NullableModelStringField, - rules::flake8_django::rules::LocalsInRenderFunction, - rules::flake8_django::rules::ExcludeWithModelForm, - rules::flake8_django::rules::AllWithModelForm, - rules::flake8_django::rules::ModelWithoutDunderStr, - rules::flake8_django::rules::NonLeadingReceiverDecorator, + rules::flake8_django::rules::DjangoNullableModelStringField, + rules::flake8_django::rules::DjangoLocalsInRenderFunction, + rules::flake8_django::rules::DjangoExcludeWithModelForm, + rules::flake8_django::rules::DjangoAllWithModelForm, + rules::flake8_django::rules::DjangoModelWithoutDunderStr, + rules::flake8_django::rules::DjangoNonLeadingReceiverDecorator, ); pub trait AsRule { @@ -841,17 +841,17 @@ impl Rule { | Rule::DocLineTooLong | Rule::LineTooLong | Rule::MixedSpacesAndTabs - | Rule::NoNewLineAtEndOfFile + | Rule::MissingNewlineAtEndOfFile | Rule::UTF8EncodingDeclaration | Rule::ShebangMissingExecutableFile | Rule::ShebangNotExecutable - | Rule::ShebangNewline + | Rule::ShebangNotFirstLine | Rule::BidirectionalUnicode - | Rule::ShebangPython - | Rule::ShebangWhitespace + | Rule::ShebangMissingPython + | Rule::ShebangLeadingWhitespace | Rule::TrailingWhitespace - | Rule::IndentationContainsTabs - | Rule::BlankLineContainsWhitespace => LintSource::PhysicalLines, + | Rule::TabIndentation + | Rule::BlankLineWithWhitespace => LintSource::PhysicalLines, Rule::AmbiguousUnicodeCharacterComment | Rule::AmbiguousUnicodeCharacterDocstring | Rule::AmbiguousUnicodeCharacterString @@ -869,12 +869,12 @@ impl Rule { | Rule::ExtraneousParentheses | Rule::InvalidEscapeSequence | Rule::SingleLineImplicitStringConcatenation - | Rule::TrailingCommaMissing - | Rule::TrailingCommaOnBareTupleProhibited + | Rule::MissingTrailingComma + | Rule::TrailingCommaOnBareTuple | Rule::MultipleStatementsOnOneLineColon | Rule::UselessSemicolon | Rule::MultipleStatementsOnOneLineSemicolon - | Rule::TrailingCommaProhibited + | Rule::ProhibitedTrailingComma | Rule::TypeCommentInStub => LintSource::Tokens, Rule::IOError => LintSource::Io, Rule::UnsortedImports | Rule::MissingRequiredImport => LintSource::Imports, @@ -919,7 +919,7 @@ impl Rule { /// Pairs of checks that shouldn't be enabled together. pub const INCOMPATIBLE_CODES: &[(Rule, Rule, &str); 2] = &[ ( - Rule::NoBlankLineBeforeClass, + Rule::BlankLineBeforeClass, Rule::OneBlankLineBeforeClass, "`one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are \ incompatible. Ignoring `one-blank-line-before-class`.", diff --git a/crates/ruff/src/rules/flake8_2020/mod.rs b/crates/ruff/src/rules/flake8_2020/mod.rs index fce40f099b..a04acb5ad7 100644 --- a/crates/ruff/src/rules/flake8_2020/mod.rs +++ b/crates/ruff/src/rules/flake8_2020/mod.rs @@ -13,16 +13,16 @@ mod tests { use crate::settings; use crate::test::test_path; - #[test_case(Rule::SysVersionSlice3Referenced, Path::new("YTT101.py"); "YTT101")] - #[test_case(Rule::SysVersion2Referenced, Path::new("YTT102.py"); "YTT102")] + #[test_case(Rule::SysVersionSlice3, Path::new("YTT101.py"); "YTT101")] + #[test_case(Rule::SysVersion2, Path::new("YTT102.py"); "YTT102")] #[test_case(Rule::SysVersionCmpStr3, Path::new("YTT103.py"); "YTT103")] - #[test_case(Rule::SysVersionInfo0Eq3Referenced, Path::new("YTT201.py"); "YTT201")] - #[test_case(Rule::SixPY3Referenced, Path::new("YTT202.py"); "YTT202")] + #[test_case(Rule::SysVersionInfo0Eq3, Path::new("YTT201.py"); "YTT201")] + #[test_case(Rule::SixPY3, Path::new("YTT202.py"); "YTT202")] #[test_case(Rule::SysVersionInfo1CmpInt, Path::new("YTT203.py"); "YTT203")] #[test_case(Rule::SysVersionInfoMinorCmpInt, Path::new("YTT204.py"); "YTT204")] - #[test_case(Rule::SysVersion0Referenced, Path::new("YTT301.py"); "YTT301")] + #[test_case(Rule::SysVersion0, Path::new("YTT301.py"); "YTT301")] #[test_case(Rule::SysVersionCmpStr10, Path::new("YTT302.py"); "YTT302")] - #[test_case(Rule::SysVersionSlice1Referenced, Path::new("YTT303.py"); "YTT303")] + #[test_case(Rule::SysVersionSlice1, Path::new("YTT303.py"); "YTT303")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_2020/rules.rs b/crates/ruff/src/rules/flake8_2020/rules.rs index 4ee4f6398f..d6f36a801d 100644 --- a/crates/ruff/src/rules/flake8_2020/rules.rs +++ b/crates/ruff/src/rules/flake8_2020/rules.rs @@ -9,9 +9,9 @@ use crate::checkers::ast::Checker; use crate::registry::Rule; #[violation] -pub struct SysVersionSlice3Referenced; +pub struct SysVersionSlice3; -impl Violation for SysVersionSlice3Referenced { +impl Violation for SysVersionSlice3 { #[derive_message_formats] fn message(&self) -> String { format!("`sys.version[:3]` referenced (python3.10), use `sys.version_info`") @@ -19,9 +19,9 @@ impl Violation for SysVersionSlice3Referenced { } #[violation] -pub struct SysVersion2Referenced; +pub struct SysVersion2; -impl Violation for SysVersion2Referenced { +impl Violation for SysVersion2 { #[derive_message_formats] fn message(&self) -> String { format!("`sys.version[2]` referenced (python3.10), use `sys.version_info`") @@ -39,9 +39,9 @@ impl Violation for SysVersionCmpStr3 { } #[violation] -pub struct SysVersionInfo0Eq3Referenced; +pub struct SysVersionInfo0Eq3; -impl Violation for SysVersionInfo0Eq3Referenced { +impl Violation for SysVersionInfo0Eq3 { #[derive_message_formats] fn message(&self) -> String { format!("`sys.version_info[0] == 3` referenced (python4), use `>=`") @@ -49,9 +49,9 @@ impl Violation for SysVersionInfo0Eq3Referenced { } #[violation] -pub struct SixPY3Referenced; +pub struct SixPY3; -impl Violation for SixPY3Referenced { +impl Violation for SixPY3 { #[derive_message_formats] fn message(&self) -> String { format!("`six.PY3` referenced (python4), use `not six.PY2`") @@ -85,9 +85,9 @@ impl Violation for SysVersionInfoMinorCmpInt { } #[violation] -pub struct SysVersion0Referenced; +pub struct SysVersion0; -impl Violation for SysVersion0Referenced { +impl Violation for SysVersion0 { #[derive_message_formats] fn message(&self) -> String { format!("`sys.version[0]` referenced (python10), use `sys.version_info`") @@ -105,9 +105,9 @@ impl Violation for SysVersionCmpStr10 { } #[violation] -pub struct SysVersionSlice1Referenced; +pub struct SysVersionSlice1; -impl Violation for SysVersionSlice1Referenced { +impl Violation for SysVersionSlice1 { #[derive_message_formats] fn message(&self) -> String { format!("`sys.version[:1]` referenced (python10), use `sys.version_info`") @@ -137,25 +137,17 @@ pub fn subscript(checker: &mut Checker, value: &Expr, slice: &Expr) { } = &upper.node { if *i == BigInt::from(1) - && checker - .settings - .rules - .enabled(Rule::SysVersionSlice1Referenced) + && checker.settings.rules.enabled(Rule::SysVersionSlice1) { - checker.diagnostics.push(Diagnostic::new( - SysVersionSlice1Referenced, - Range::from(value), - )); + checker + .diagnostics + .push(Diagnostic::new(SysVersionSlice1, Range::from(value))); } else if *i == BigInt::from(3) - && checker - .settings - .rules - .enabled(Rule::SysVersionSlice3Referenced) + && checker.settings.rules.enabled(Rule::SysVersionSlice3) { - checker.diagnostics.push(Diagnostic::new( - SysVersionSlice3Referenced, - Range::from(value), - )); + checker + .diagnostics + .push(Diagnostic::new(SysVersionSlice3, Range::from(value))); } } } @@ -164,18 +156,15 @@ pub fn subscript(checker: &mut Checker, value: &Expr, slice: &Expr) { value: Constant::Int(i), .. } => { - if *i == BigInt::from(2) - && checker.settings.rules.enabled(Rule::SysVersion2Referenced) + if *i == BigInt::from(2) && checker.settings.rules.enabled(Rule::SysVersion2) { + checker + .diagnostics + .push(Diagnostic::new(SysVersion2, Range::from(value))); + } else if *i == BigInt::from(0) && checker.settings.rules.enabled(Rule::SysVersion0) { checker .diagnostics - .push(Diagnostic::new(SysVersion2Referenced, Range::from(value))); - } else if *i == BigInt::from(0) - && checker.settings.rules.enabled(Rule::SysVersion0Referenced) - { - checker - .diagnostics - .push(Diagnostic::new(SysVersion0Referenced, Range::from(value))); + .push(Diagnostic::new(SysVersion0, Range::from(value))); } } @@ -207,15 +196,11 @@ pub fn compare(checker: &mut Checker, left: &Expr, ops: &[Cmpop], comparators: & ) = (ops, comparators) { if *n == BigInt::from(3) - && checker - .settings - .rules - .enabled(Rule::SysVersionInfo0Eq3Referenced) + && checker.settings.rules.enabled(Rule::SysVersionInfo0Eq3) { - checker.diagnostics.push(Diagnostic::new( - SysVersionInfo0Eq3Referenced, - Range::from(left), - )); + checker + .diagnostics + .push(Diagnostic::new(SysVersionInfo0Eq3, Range::from(left))); } } } else if *i == BigInt::from(1) { @@ -309,6 +294,6 @@ pub fn name_or_attribute(checker: &mut Checker, expr: &Expr) { { checker .diagnostics - .push(Diagnostic::new(SixPY3Referenced, Range::from(expr))); + .push(Diagnostic::new(SixPY3, Range::from(expr))); } } diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap index a36bfc1243..8e5fce3732 100644 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap +++ b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_2020/mod.rs expression: diagnostics --- - kind: - name: SysVersionSlice3Referenced + name: SysVersionSlice3 body: "`sys.version[:3]` referenced (python3.10), use `sys.version_info`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersionSlice3Referenced + name: SysVersionSlice3 body: "`sys.version[:3]` referenced (python3.10), use `sys.version_info`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersionSlice3Referenced + name: SysVersionSlice3 body: "`sys.version[:3]` referenced (python3.10), use `sys.version_info`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap index 11c4039b42..e9f6140fb3 100644 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap +++ b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_2020/mod.rs expression: diagnostics --- - kind: - name: SysVersion2Referenced + name: SysVersion2 body: "`sys.version[2]` referenced (python3.10), use `sys.version_info`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersion2Referenced + name: SysVersion2 body: "`sys.version[2]` referenced (python3.10), use `sys.version_info`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap index ee9961efc1..35226f04de 100644 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap +++ b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_2020/mod.rs expression: diagnostics --- - kind: - name: SysVersionInfo0Eq3Referenced + name: SysVersionInfo0Eq3 body: "`sys.version_info[0] == 3` referenced (python4), use `>=`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersionInfo0Eq3Referenced + name: SysVersionInfo0Eq3 body: "`sys.version_info[0] == 3` referenced (python4), use `>=`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersionInfo0Eq3Referenced + name: SysVersionInfo0Eq3 body: "`sys.version_info[0] == 3` referenced (python4), use `>=`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersionInfo0Eq3Referenced + name: SysVersionInfo0Eq3 body: "`sys.version_info[0] == 3` referenced (python4), use `>=`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap index e86c12a99c..0084bdb20b 100644 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap +++ b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_2020/mod.rs expression: diagnostics --- - kind: - name: SixPY3Referenced + name: SixPY3 body: "`six.PY3` referenced (python4), use `not six.PY2`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SixPY3Referenced + name: SixPY3 body: "`six.PY3` referenced (python4), use `not six.PY2`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap index 2e154875fa..4c82503d66 100644 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap +++ b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_2020/mod.rs expression: diagnostics --- - kind: - name: SysVersion0Referenced + name: SysVersion0 body: "`sys.version[0]` referenced (python10), use `sys.version_info`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersion0Referenced + name: SysVersion0 body: "`sys.version[0]` referenced (python10), use `sys.version_info`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap index 7ea49bfead..2918739e12 100644 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap +++ b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_2020/mod.rs expression: diagnostics --- - kind: - name: SysVersionSlice1Referenced + name: SysVersionSlice1 body: "`sys.version[:1]` referenced (python10), use `sys.version_info`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: SysVersionSlice1Referenced + name: SysVersionSlice1 body: "`sys.version[:1]` referenced (python10), use `sys.version_info`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_annotations/mod.rs b/crates/ruff/src/rules/flake8_annotations/mod.rs index 384c82b1cf..f3d57a2758 100644 --- a/crates/ruff/src/rules/flake8_annotations/mod.rs +++ b/crates/ruff/src/rules/flake8_annotations/mod.rs @@ -26,7 +26,7 @@ mod tests { Rule::MissingTypeKwargs, Rule::MissingTypeSelf, Rule::MissingTypeCls, - Rule::MissingReturnTypePublicFunction, + Rule::MissingReturnTypeUndocumentedPublicFunction, Rule::MissingReturnTypePrivateFunction, Rule::MissingReturnTypeSpecialMethod, Rule::MissingReturnTypeStaticMethod, @@ -54,7 +54,7 @@ mod tests { Rule::MissingTypeKwargs, Rule::MissingTypeSelf, Rule::MissingTypeCls, - Rule::MissingReturnTypePublicFunction, + Rule::MissingReturnTypeUndocumentedPublicFunction, Rule::MissingReturnTypePrivateFunction, Rule::MissingReturnTypeSpecialMethod, Rule::MissingReturnTypeStaticMethod, @@ -99,7 +99,7 @@ mod tests { ..Default::default() }, ..Settings::for_rules(vec![ - Rule::MissingReturnTypePublicFunction, + Rule::MissingReturnTypeUndocumentedPublicFunction, Rule::MissingReturnTypePrivateFunction, Rule::MissingReturnTypeSpecialMethod, Rule::MissingReturnTypeStaticMethod, @@ -126,7 +126,7 @@ mod tests { Rule::MissingTypeKwargs, Rule::MissingTypeSelf, Rule::MissingTypeCls, - Rule::MissingReturnTypePublicFunction, + Rule::MissingReturnTypeUndocumentedPublicFunction, Rule::MissingReturnTypePrivateFunction, Rule::MissingReturnTypeSpecialMethod, Rule::MissingReturnTypeStaticMethod, @@ -161,7 +161,7 @@ mod tests { Path::new("flake8_annotations/allow_overload.py"), &Settings { ..Settings::for_rules(vec![ - Rule::MissingReturnTypePublicFunction, + Rule::MissingReturnTypeUndocumentedPublicFunction, Rule::MissingReturnTypePrivateFunction, Rule::MissingReturnTypeSpecialMethod, Rule::MissingReturnTypeStaticMethod, @@ -179,7 +179,7 @@ mod tests { Path::new("flake8_annotations/allow_nested_overload.py"), &Settings { ..Settings::for_rules(vec![ - Rule::MissingReturnTypePublicFunction, + Rule::MissingReturnTypeUndocumentedPublicFunction, Rule::MissingReturnTypePrivateFunction, Rule::MissingReturnTypeSpecialMethod, Rule::MissingReturnTypeStaticMethod, diff --git a/crates/ruff/src/rules/flake8_annotations/rules.rs b/crates/ruff/src/rules/flake8_annotations/rules.rs index fac4201b44..d4152a1263 100644 --- a/crates/ruff/src/rules/flake8_annotations/rules.rs +++ b/crates/ruff/src/rules/flake8_annotations/rules.rs @@ -209,14 +209,14 @@ impl Violation for MissingTypeCls { /// return a + b /// ``` #[violation] -pub struct MissingReturnTypePublicFunction { +pub struct MissingReturnTypeUndocumentedPublicFunction { pub name: String, } -impl Violation for MissingReturnTypePublicFunction { +impl Violation for MissingReturnTypeUndocumentedPublicFunction { #[derive_message_formats] fn message(&self) -> String { - let MissingReturnTypePublicFunction { name } = self; + let MissingReturnTypeUndocumentedPublicFunction { name } = self; format!("Missing return type annotation for public function `{name}`") } } @@ -696,10 +696,10 @@ pub fn definition( if checker .settings .rules - .enabled(Rule::MissingReturnTypePublicFunction) + .enabled(Rule::MissingReturnTypeUndocumentedPublicFunction) { diagnostics.push(Diagnostic::new( - MissingReturnTypePublicFunction { + MissingReturnTypeUndocumentedPublicFunction { name: name.to_string(), }, helpers::identifier_range(stmt, checker.locator), diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap index f353af891e..128ef39866 100644 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap +++ b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_annotations/mod.rs expression: diagnostics --- - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `bar`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap index fdfde38878..d81296dc2d 100644 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap +++ b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_annotations/mod.rs expression: diagnostics --- - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `foo`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `foo`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `foo`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `foo`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap index e6d963bfb1..aa273cbd22 100644 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap +++ b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_annotations/mod.rs expression: diagnostics --- - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `error_partially_typed_1`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `error_partially_typed_3`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `error_typed_self`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap index 1298897256..575a188f2a 100644 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap +++ b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_annotations/mod.rs expression: diagnostics --- - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `foo`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingReturnTypePublicFunction + name: MissingReturnTypeUndocumentedPublicFunction body: "Missing return type annotation for public function `foo`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_bugbear/mod.rs b/crates/ruff/src/rules/flake8_bugbear/mod.rs index 4f3a166ee5..961506279b 100644 --- a/crates/ruff/src/rules/flake8_bugbear/mod.rs +++ b/crates/ruff/src/rules/flake8_bugbear/mod.rs @@ -20,7 +20,7 @@ mod tests { #[test_case(Rule::StripWithMultiCharacters, Path::new("B005.py"); "B005")] #[test_case(Rule::MutableArgumentDefault, Path::new("B006_B008.py"); "B006")] #[test_case(Rule::UnusedLoopControlVariable, Path::new("B007.py"); "B007")] - #[test_case(Rule::FunctionCallArgumentDefault, Path::new("B006_B008.py"); "B008")] + #[test_case(Rule::FunctionCallInDefaultArgument, Path::new("B006_B008.py"); "B008")] #[test_case(Rule::GetAttrWithConstant, Path::new("B009_B010.py"); "B009")] #[test_case(Rule::SetAttrWithConstant, Path::new("B009_B010.py"); "B010")] #[test_case(Rule::AssertFalse, Path::new("B011.py"); "B011")] @@ -69,7 +69,7 @@ mod tests { "fastapi.Query".to_string(), ], }, - ..Settings::for_rules(vec![Rule::FunctionCallArgumentDefault]) + ..Settings::for_rules(vec![Rule::FunctionCallInDefaultArgument]) }, )?; assert_yaml_snapshot!(snapshot, diagnostics); diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs b/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs index a4e17480ae..96002eb3ff 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs @@ -13,14 +13,14 @@ use crate::checkers::ast::Checker; use super::mutable_argument_default::is_mutable_func; #[violation] -pub struct FunctionCallArgumentDefault { +pub struct FunctionCallInDefaultArgument { pub name: Option, } -impl Violation for FunctionCallArgumentDefault { +impl Violation for FunctionCallInDefaultArgument { #[derive_message_formats] fn message(&self) -> String { - let FunctionCallArgumentDefault { name } = self; + let FunctionCallInDefaultArgument { name } = self; if let Some(name) = name { format!("Do not perform function call `{name}` in argument defaults") } else { @@ -71,7 +71,7 @@ where && !is_nan_or_infinity(func, args) { self.diagnostics.push(( - FunctionCallArgumentDefault { + FunctionCallInDefaultArgument { name: compose_call_path(func), } .into(), diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/mod.rs b/crates/ruff/src/rules/flake8_bugbear/rules/mod.rs index 7802109c4e..d672d298e8 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/mod.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/mod.rs @@ -16,7 +16,7 @@ pub use except_with_non_exception_classes::{ }; pub use f_string_docstring::{f_string_docstring, FStringDocstring}; pub use function_call_argument_default::{ - function_call_argument_default, FunctionCallArgumentDefault, + function_call_argument_default, FunctionCallInDefaultArgument, }; pub use function_uses_loop_variable::{function_uses_loop_variable, FunctionUsesLoopVariable}; pub use getattr_with_constant::{getattr_with_constant, GetAttrWithConstant}; diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap index 386b09cf51..41c0a8993c 100644 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_bugbear/mod.rs expression: diagnostics --- - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `range` in argument defaults" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `range` in argument defaults" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `range` in argument defaults" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `time.time` in argument defaults" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `dt.datetime.now` in argument defaults" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `dt.timedelta` in argument defaults" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: Do not perform function call in argument defaults suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `float` in argument defaults" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `float` in argument defaults" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `float` in argument defaults" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `float` in argument defaults" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `dt.datetime.now` in argument defaults" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `map` in argument defaults" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `random.randint` in argument defaults" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `dt.datetime.now` in argument defaults" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls.snap index 0812483b42..0470194350 100644 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls.snap +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_bugbear/mod.rs expression: diagnostics --- - kind: - name: FunctionCallArgumentDefault + name: FunctionCallInDefaultArgument body: "Do not perform function call `Depends` in argument defaults" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_commas/mod.rs b/crates/ruff/src/rules/flake8_commas/mod.rs index 06350675cc..a2278f4457 100644 --- a/crates/ruff/src/rules/flake8_commas/mod.rs +++ b/crates/ruff/src/rules/flake8_commas/mod.rs @@ -19,9 +19,9 @@ mod tests { let diagnostics = test_path( Path::new("flake8_commas").join(path).as_path(), &settings::Settings::for_rules(vec![ - Rule::TrailingCommaMissing, - Rule::TrailingCommaOnBareTupleProhibited, - Rule::TrailingCommaProhibited, + Rule::MissingTrailingComma, + Rule::TrailingCommaOnBareTuple, + Rule::ProhibitedTrailingComma, ]), )?; assert_yaml_snapshot!(snapshot, diagnostics); diff --git a/crates/ruff/src/rules/flake8_commas/rules.rs b/crates/ruff/src/rules/flake8_commas/rules.rs index fdc57be813..50f6b83d37 100644 --- a/crates/ruff/src/rules/flake8_commas/rules.rs +++ b/crates/ruff/src/rules/flake8_commas/rules.rs @@ -111,9 +111,9 @@ impl Context { } #[violation] -pub struct TrailingCommaMissing; +pub struct MissingTrailingComma; -impl AlwaysAutofixableViolation for TrailingCommaMissing { +impl AlwaysAutofixableViolation for MissingTrailingComma { #[derive_message_formats] fn message(&self) -> String { format!("Trailing comma missing") @@ -125,9 +125,9 @@ impl AlwaysAutofixableViolation for TrailingCommaMissing { } #[violation] -pub struct TrailingCommaOnBareTupleProhibited; +pub struct TrailingCommaOnBareTuple; -impl Violation for TrailingCommaOnBareTupleProhibited { +impl Violation for TrailingCommaOnBareTuple { #[derive_message_formats] fn message(&self) -> String { format!("Trailing comma on bare tuple prohibited") @@ -135,9 +135,9 @@ impl Violation for TrailingCommaOnBareTupleProhibited { } #[violation] -pub struct TrailingCommaProhibited; +pub struct ProhibitedTrailingComma; -impl AlwaysAutofixableViolation for TrailingCommaProhibited { +impl AlwaysAutofixableViolation for ProhibitedTrailingComma { #[derive_message_formats] fn message(&self) -> String { format!("Trailing comma prohibited") @@ -254,13 +254,13 @@ pub fn trailing_commas( if comma_prohibited { let comma = prev.spanned.unwrap(); let mut diagnostic = Diagnostic::new( - TrailingCommaProhibited, + ProhibitedTrailingComma, Range { location: comma.0, end_location: comma.2, }, ); - if autofix.into() && settings.rules.should_fix(Rule::TrailingCommaProhibited) { + if autofix.into() && settings.rules.should_fix(Rule::ProhibitedTrailingComma) { diagnostic.amend(Fix::deletion(comma.0, comma.2)); } diagnostics.push(diagnostic); @@ -273,7 +273,7 @@ pub fn trailing_commas( if bare_comma_prohibited { let comma = prev.spanned.unwrap(); diagnostics.push(Diagnostic::new( - TrailingCommaOnBareTupleProhibited, + TrailingCommaOnBareTuple, Range { location: comma.0, end_location: comma.2, @@ -298,13 +298,13 @@ pub fn trailing_commas( if comma_required { let missing_comma = prev_prev.spanned.unwrap(); let mut diagnostic = Diagnostic::new( - TrailingCommaMissing, + MissingTrailingComma, Range { location: missing_comma.2, end_location: missing_comma.2, }, ); - if autofix.into() && settings.rules.should_fix(Rule::TrailingCommaMissing) { + if autofix.into() && settings.rules.should_fix(Rule::MissingTrailingComma) { // Create a replacement that includes the final bracket (or other token), // rather than just inserting a comma at the end. This prevents the UP034 autofix // removing any brackets in the same linter pass - doing both at the same time could diff --git a/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap b/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap index 13fac3667e..cdc936e53e 100644 --- a/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap +++ b/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_commas/mod.rs expression: diagnostics --- - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 17 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -96,7 +96,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -109,7 +109,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -122,7 +122,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -135,7 +135,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -148,7 +148,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -161,7 +161,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaOnBareTupleProhibited + name: TrailingCommaOnBareTuple body: Trailing comma on bare tuple prohibited suggestion: ~ fixable: false @@ -174,7 +174,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -194,7 +194,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -214,7 +214,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -234,7 +234,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -254,7 +254,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -274,7 +274,7 @@ expression: diagnostics column: 10 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -294,7 +294,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -314,7 +314,7 @@ expression: diagnostics column: 13 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -334,7 +334,7 @@ expression: diagnostics column: 13 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -354,7 +354,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -374,7 +374,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -394,7 +394,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -414,7 +414,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -434,7 +434,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -454,7 +454,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -474,7 +474,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -494,7 +494,7 @@ expression: diagnostics column: 13 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -514,7 +514,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -534,7 +534,7 @@ expression: diagnostics column: 6 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -554,7 +554,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -574,7 +574,7 @@ expression: diagnostics column: 13 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -594,7 +594,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -614,7 +614,7 @@ expression: diagnostics column: 6 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -634,7 +634,7 @@ expression: diagnostics column: 10 parent: ~ - kind: - name: TrailingCommaProhibited + name: ProhibitedTrailingComma body: Trailing comma prohibited suggestion: Remove trailing comma fixable: true @@ -654,7 +654,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -674,7 +674,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -694,7 +694,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -714,7 +714,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -734,7 +734,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -754,7 +754,7 @@ expression: diagnostics column: 23 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -774,7 +774,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -794,7 +794,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -814,7 +814,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -834,7 +834,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -854,7 +854,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -874,7 +874,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -894,7 +894,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -914,7 +914,7 @@ expression: diagnostics column: 14 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true @@ -934,7 +934,7 @@ expression: diagnostics column: 19 parent: ~ - kind: - name: TrailingCommaMissing + name: MissingTrailingComma body: Trailing comma missing suggestion: Add trailing comma fixable: true diff --git a/crates/ruff/src/rules/flake8_django/mod.rs b/crates/ruff/src/rules/flake8_django/mod.rs index 99ad2807fc..2fcc260c0c 100644 --- a/crates/ruff/src/rules/flake8_django/mod.rs +++ b/crates/ruff/src/rules/flake8_django/mod.rs @@ -13,12 +13,12 @@ mod tests { use crate::settings; use crate::test::test_path; - #[test_case(Rule::NullableModelStringField, Path::new("DJ001.py"); "DJ001")] - #[test_case(Rule::LocalsInRenderFunction, Path::new("DJ003.py"); "DJ003")] - #[test_case(Rule::ExcludeWithModelForm, Path::new("DJ006.py"); "DJ006")] - #[test_case(Rule::AllWithModelForm, Path::new("DJ007.py"); "DJ007")] - #[test_case(Rule::ModelWithoutDunderStr, Path::new("DJ008.py"); "DJ008")] - #[test_case(Rule::NonLeadingReceiverDecorator, Path::new("DJ013.py"); "DJ013")] + #[test_case(Rule::DjangoNullableModelStringField, Path::new("DJ001.py"); "DJ001")] + #[test_case(Rule::DjangoLocalsInRenderFunction, Path::new("DJ003.py"); "DJ003")] + #[test_case(Rule::DjangoExcludeWithModelForm, Path::new("DJ006.py"); "DJ006")] + #[test_case(Rule::DjangoAllWithModelForm, Path::new("DJ007.py"); "DJ007")] + #[test_case(Rule::DjangoModelWithoutDunderStr, Path::new("DJ008.py"); "DJ008")] + #[test_case(Rule::DjangoNonLeadingReceiverDecorator, Path::new("DJ013.py"); "DJ013")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs b/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs index c8e3c20bbf..6d8235ce74 100644 --- a/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs +++ b/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs @@ -38,9 +38,9 @@ use crate::rules::flake8_django::rules::helpers::is_model_form; /// fields = ["title", "content"] /// ``` #[violation] -pub struct AllWithModelForm; +pub struct DjangoAllWithModelForm; -impl Violation for AllWithModelForm { +impl Violation for DjangoAllWithModelForm { #[derive_message_formats] fn message(&self) -> String { format!("Do not use `__all__` with `ModelForm`, use `fields` instead") @@ -76,12 +76,18 @@ pub fn all_with_model_form(checker: &Checker, bases: &[Expr], body: &[Stmt]) -> match &value { Constant::Str(s) => { if s == "__all__" { - return Some(Diagnostic::new(AllWithModelForm, Range::from(element))); + return Some(Diagnostic::new( + DjangoAllWithModelForm, + Range::from(element), + )); } } Constant::Bytes(b) => { if b == "__all__".as_bytes() { - return Some(Diagnostic::new(AllWithModelForm, Range::from(element))); + return Some(Diagnostic::new( + DjangoAllWithModelForm, + Range::from(element), + )); } } _ => (), diff --git a/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs b/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs index e79c7732d2..fe5c97be42 100644 --- a/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs +++ b/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs @@ -34,9 +34,9 @@ use crate::rules::flake8_django::rules::helpers::is_model_form; /// fields = ["title", "content"] /// ``` #[violation] -pub struct ExcludeWithModelForm; +pub struct DjangoExcludeWithModelForm; -impl Violation for ExcludeWithModelForm { +impl Violation for DjangoExcludeWithModelForm { #[derive_message_formats] fn message(&self) -> String { format!("Do not use `exclude` with `ModelForm`, use `fields` instead") @@ -68,7 +68,10 @@ pub fn exclude_with_model_form( continue; }; if id == "exclude" { - return Some(Diagnostic::new(ExcludeWithModelForm, Range::from(target))); + return Some(Diagnostic::new( + DjangoExcludeWithModelForm, + Range::from(target), + )); } } } diff --git a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs b/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs index e1c761f153..ea44e83220 100644 --- a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs +++ b/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs @@ -32,9 +32,9 @@ use crate::checkers::ast::Checker; /// return render(request, "app/index.html", context) /// ``` #[violation] -pub struct LocalsInRenderFunction; +pub struct DjangoLocalsInRenderFunction; -impl Violation for LocalsInRenderFunction { +impl Violation for DjangoLocalsInRenderFunction { #[derive_message_formats] fn message(&self) -> String { format!("Avoid passing `locals()` as context to a `render` function") @@ -78,9 +78,10 @@ pub fn locals_in_render_function( return; }; - checker - .diagnostics - .push(Diagnostic::new(LocalsInRenderFunction, Range::from(locals))); + checker.diagnostics.push(Diagnostic::new( + DjangoLocalsInRenderFunction, + Range::from(locals), + )); } fn is_locals_call(checker: &Checker, expr: &Expr) -> bool { diff --git a/crates/ruff/src/rules/flake8_django/rules/mod.rs b/crates/ruff/src/rules/flake8_django/rules/mod.rs index 85be2d14e1..8f5190a71e 100644 --- a/crates/ruff/src/rules/flake8_django/rules/mod.rs +++ b/crates/ruff/src/rules/flake8_django/rules/mod.rs @@ -1,11 +1,13 @@ -pub use all_with_model_form::{all_with_model_form, AllWithModelForm}; -pub use exclude_with_model_form::{exclude_with_model_form, ExcludeWithModelForm}; -pub use locals_in_render_function::{locals_in_render_function, LocalsInRenderFunction}; -pub use model_without_dunder_str::{model_without_dunder_str, ModelWithoutDunderStr}; +pub use all_with_model_form::{all_with_model_form, DjangoAllWithModelForm}; +pub use exclude_with_model_form::{exclude_with_model_form, DjangoExcludeWithModelForm}; +pub use locals_in_render_function::{locals_in_render_function, DjangoLocalsInRenderFunction}; +pub use model_without_dunder_str::{model_without_dunder_str, DjangoModelWithoutDunderStr}; pub use non_leading_receiver_decorator::{ - non_leading_receiver_decorator, NonLeadingReceiverDecorator, + non_leading_receiver_decorator, DjangoNonLeadingReceiverDecorator, +}; +pub use nullable_model_string_field::{ + nullable_model_string_field, DjangoNullableModelStringField, }; -pub use nullable_model_string_field::{nullable_model_string_field, NullableModelStringField}; mod all_with_model_form; mod exclude_with_model_form; diff --git a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs b/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs index 7ca6f1bd0a..124e0efd99 100644 --- a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs +++ b/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs @@ -41,9 +41,9 @@ use super::helpers; /// return f"{self.field}" /// ``` #[violation] -pub struct ModelWithoutDunderStr; +pub struct DjangoModelWithoutDunderStr; -impl Violation for ModelWithoutDunderStr { +impl Violation for DjangoModelWithoutDunderStr { #[derive_message_formats] fn message(&self) -> String { format!("Model does not define `__str__` method") @@ -62,7 +62,7 @@ pub fn model_without_dunder_str( } if !has_dunder_method(body) { return Some(Diagnostic::new( - ModelWithoutDunderStr, + DjangoModelWithoutDunderStr, Range::from(class_location), )); } diff --git a/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs b/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs index 42e7711ee7..20888318d4 100644 --- a/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs +++ b/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs @@ -38,9 +38,9 @@ use ruff_python_ast::types::{CallPath, Range}; /// pass /// ``` #[violation] -pub struct NonLeadingReceiverDecorator; +pub struct DjangoNonLeadingReceiverDecorator; -impl Violation for NonLeadingReceiverDecorator { +impl Violation for DjangoNonLeadingReceiverDecorator { #[derive_message_formats] fn message(&self) -> String { format!("`@receiver` decorator must be on top of all the other decorators") @@ -66,7 +66,7 @@ where }; if i > 0 && is_receiver && !seen_receiver { diagnostics.push(Diagnostic::new( - NonLeadingReceiverDecorator, + DjangoNonLeadingReceiverDecorator, Range::from(decorator), )); } diff --git a/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs b/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs index f29abc8c35..58f05c24a9 100644 --- a/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs +++ b/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs @@ -40,14 +40,14 @@ use super::helpers; /// field = models.CharField(max_length=255, default="") /// ``` #[violation] -pub struct NullableModelStringField { +pub struct DjangoNullableModelStringField { pub field_name: String, } -impl Violation for NullableModelStringField { +impl Violation for DjangoNullableModelStringField { #[derive_message_formats] fn message(&self) -> String { - let NullableModelStringField { field_name } = self; + let DjangoNullableModelStringField { field_name } = self; format!("Avoid using `null=True` on string-based fields such as {field_name}") } } @@ -70,7 +70,7 @@ pub fn nullable_model_string_field(checker: &Checker, body: &[Stmt]) -> Vec String { format!("Shebang should be at the beginning of the file") @@ -21,7 +21,7 @@ pub fn shebang_newline(lineno: usize, shebang: &ShebangDirective) -> Option 1 { let diagnostic = Diagnostic::new( - ShebangNewline, + ShebangNotFirstLine, Range::new( Location::new(lineno + 1, *start), Location::new(lineno + 1, *end), diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_python.rs b/crates/ruff/src/rules/flake8_executable/rules/shebang_python.rs index 16a5be310e..be768bd967 100644 --- a/crates/ruff/src/rules/flake8_executable/rules/shebang_python.rs +++ b/crates/ruff/src/rules/flake8_executable/rules/shebang_python.rs @@ -7,9 +7,9 @@ use ruff_python_ast::types::Range; use crate::rules::flake8_executable::helpers::ShebangDirective; #[violation] -pub struct ShebangPython; +pub struct ShebangMissingPython; -impl Violation for ShebangPython { +impl Violation for ShebangMissingPython { #[derive_message_formats] fn message(&self) -> String { format!("Shebang should contain `python`") @@ -23,7 +23,7 @@ pub fn shebang_python(lineno: usize, shebang: &ShebangDirective) -> Option String { format!("Avoid whitespace before shebang") @@ -29,7 +29,7 @@ pub fn shebang_whitespace( if let ShebangDirective::Match(n_spaces, start, ..) = shebang { if *n_spaces > 0 && *start == n_spaces + 2 { let mut diagnostic = Diagnostic::new( - ShebangWhitespace, + ShebangLeadingWhitespace, Range::new( Location::new(lineno + 1, 0), Location::new(lineno + 1, *n_spaces), diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap index 8d9a6c2dc8..568ca113e0 100644 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap +++ b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_executable/mod.rs expression: diagnostics --- - kind: - name: ShebangPython + name: ShebangMissingPython body: "Shebang should contain `python`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap index 2b620ef8f2..fb781d1198 100644 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap +++ b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_executable/mod.rs expression: diagnostics --- - kind: - name: ShebangWhitespace + name: ShebangLeadingWhitespace body: Avoid whitespace before shebang suggestion: Remove whitespace before shebang fixable: true diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap index 8fbfcb1d55..292472d5c5 100644 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap +++ b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_executable/mod.rs expression: diagnostics --- - kind: - name: ShebangNewline + name: ShebangNotFirstLine body: Shebang should be at the beginning of the file suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap index d061b2485e..f6258b4dfb 100644 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap +++ b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_executable/mod.rs expression: diagnostics --- - kind: - name: ShebangNewline + name: ShebangNotFirstLine body: Shebang should be at the beginning of the file suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap index cfe1e98189..46b0655e08 100644 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap +++ b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_executable/mod.rs expression: diagnostics --- - kind: - name: ShebangNewline + name: ShebangNotFirstLine body: Shebang should be at the beginning of the file suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pie/mod.rs b/crates/ruff/src/rules/flake8_pie/mod.rs index 654e6f83c9..4d2629740f 100644 --- a/crates/ruff/src/rules/flake8_pie/mod.rs +++ b/crates/ruff/src/rules/flake8_pie/mod.rs @@ -14,13 +14,13 @@ mod tests { use crate::settings; use crate::test::test_path; - #[test_case(Rule::DupeClassFieldDefinitions, Path::new("PIE794.py"); "PIE794")] + #[test_case(Rule::DuplicateClassFieldDefinition, Path::new("PIE794.py"); "PIE794")] #[test_case(Rule::UnnecessaryDictKwargs, Path::new("PIE804.py"); "PIE804")] - #[test_case(Rule::SingleStartsEndsWith, Path::new("PIE810.py"); "PIE810")] + #[test_case(Rule::MultipleStartsEndsWith, Path::new("PIE810.py"); "PIE810")] #[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")] + #[test_case(Rule::ReimplementedListBuiltin, Path::new("PIE807.py"); "PIE807")] + #[test_case(Rule::NonUniqueEnums, Path::new("PIE796.py"); "PIE796")] #[test_case(Rule::UnnecessaryComprehensionAnyAll, Path::new("PIE802.py"); "PIE802")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); diff --git a/crates/ruff/src/rules/flake8_pie/rules.rs b/crates/ruff/src/rules/flake8_pie/rules.rs index aa733a8eb5..9624711d63 100644 --- a/crates/ruff/src/rules/flake8_pie/rules.rs +++ b/crates/ruff/src/rules/flake8_pie/rules.rs @@ -39,30 +39,30 @@ impl AlwaysAutofixableViolation for UnnecessaryPass { } #[violation] -pub struct DupeClassFieldDefinitions(pub String); +pub struct DuplicateClassFieldDefinition(pub String); -impl AlwaysAutofixableViolation for DupeClassFieldDefinitions { +impl AlwaysAutofixableViolation for DuplicateClassFieldDefinition { #[derive_message_formats] fn message(&self) -> String { - let DupeClassFieldDefinitions(name) = self; + let DuplicateClassFieldDefinition(name) = self; format!("Class field `{name}` is defined multiple times") } fn autofix_title(&self) -> String { - let DupeClassFieldDefinitions(name) = self; + let DuplicateClassFieldDefinition(name) = self; format!("Remove duplicate field definition for `{name}`") } } #[violation] -pub struct PreferUniqueEnums { +pub struct NonUniqueEnums { pub value: String, } -impl Violation for PreferUniqueEnums { +impl Violation for NonUniqueEnums { #[derive_message_formats] fn message(&self) -> String { - let PreferUniqueEnums { value } = self; + let NonUniqueEnums { value } = self; format!("Enum contains duplicate value: `{value}`") } } @@ -122,19 +122,19 @@ impl Violation for UnnecessarySpread { } #[violation] -pub struct SingleStartsEndsWith { +pub struct MultipleStartsEndsWith { pub attr: String, } -impl AlwaysAutofixableViolation for SingleStartsEndsWith { +impl AlwaysAutofixableViolation for MultipleStartsEndsWith { #[derive_message_formats] fn message(&self) -> String { - let SingleStartsEndsWith { attr } = self; + let MultipleStartsEndsWith { attr } = self; format!("Call `{attr}` once with a `tuple`") } fn autofix_title(&self) -> String { - let SingleStartsEndsWith { attr } = self; + let MultipleStartsEndsWith { attr } = self; format!("Merge into a single `{attr}` call") } } @@ -150,9 +150,9 @@ impl Violation for UnnecessaryDictKwargs { } #[violation] -pub struct PreferListBuiltin; +pub struct ReimplementedListBuiltin; -impl AlwaysAutofixableViolation for PreferListBuiltin { +impl AlwaysAutofixableViolation for ReimplementedListBuiltin { #[derive_message_formats] fn message(&self) -> String { format!("Prefer `list` over useless lambda") @@ -216,7 +216,7 @@ pub fn no_unnecessary_pass(checker: &mut Checker, body: &[Stmt]) { } /// PIE794 -pub fn dupe_class_field_definitions<'a, 'b>( +pub fn duplicate_class_field_definition<'a, 'b>( checker: &mut Checker<'a>, parent: &'b Stmt, body: &'b [Stmt], @@ -249,7 +249,7 @@ pub fn dupe_class_field_definitions<'a, 'b>( if !seen_targets.insert(target) { let mut diagnostic = Diagnostic::new( - DupeClassFieldDefinitions(target.to_string()), + DuplicateClassFieldDefinition(target.to_string()), Range::from(stmt), ); if checker.patch(diagnostic.kind.rule()) { @@ -278,7 +278,7 @@ pub fn dupe_class_field_definitions<'a, 'b>( } /// PIE796 -pub fn prefer_unique_enums<'a, 'b>(checker: &mut Checker<'a>, parent: &'b Stmt, body: &'b [Stmt]) +pub fn non_unique_enums<'a, 'b>(checker: &mut Checker<'a>, parent: &'b Stmt, body: &'b [Stmt]) where 'b: 'a, { @@ -313,7 +313,7 @@ where if !seen_targets.insert(ComparableExpr::from(value)) { let diagnostic = Diagnostic::new( - PreferUniqueEnums { + NonUniqueEnums { value: unparse_expr(value, checker.stylist), }, Range::from(stmt), @@ -324,7 +324,7 @@ where } /// PIE800 -pub fn no_unnecessary_spread(checker: &mut Checker, keys: &[Option], values: &[Expr]) { +pub fn unnecessary_spread(checker: &mut Checker, keys: &[Option], values: &[Expr]) { for item in keys.iter().zip(values.iter()) { if let (None, value) = item { // We only care about when the key is None which indicates a spread `**` @@ -384,7 +384,7 @@ fn is_valid_kwarg_name(key: &Expr) -> bool { } /// PIE804 -pub fn no_unnecessary_dict_kwargs(checker: &mut Checker, expr: &Expr, kwargs: &[Keyword]) { +pub fn unnecessary_dict_kwargs(checker: &mut Checker, expr: &Expr, kwargs: &[Keyword]) { for kw in kwargs { // keyword is a spread operator (indicated by None) if kw.node.arg.is_none() { @@ -403,7 +403,7 @@ pub fn no_unnecessary_dict_kwargs(checker: &mut Checker, expr: &Expr, kwargs: &[ } /// PIE810 -pub fn single_starts_ends_with(checker: &mut Checker, expr: &Expr) { +pub fn multiple_starts_ends_with(checker: &mut Checker, expr: &Expr) { let ExprKind::BoolOp { op: Boolop::Or, values } = &expr.node else { return; }; @@ -445,7 +445,7 @@ pub fn single_starts_ends_with(checker: &mut Checker, expr: &Expr) { for ((attr_name, arg_name), indices) in duplicates { if indices.len() > 1 { let mut diagnostic = Diagnostic::new( - SingleStartsEndsWith { + MultipleStartsEndsWith { attr: attr_name.to_string(), }, Range::from(expr), @@ -518,7 +518,7 @@ pub fn single_starts_ends_with(checker: &mut Checker, expr: &Expr) { } /// PIE807 -pub fn prefer_list_builtin(checker: &mut Checker, expr: &Expr) { +pub fn reimplemented_list_builtin(checker: &mut Checker, expr: &Expr) { let ExprKind::Lambda { args, body } = &expr.node else { unreachable!("Expected ExprKind::Lambda"); }; @@ -530,7 +530,7 @@ pub fn prefer_list_builtin(checker: &mut Checker, expr: &Expr) { { if let ExprKind::List { elts, .. } = &body.node { if elts.is_empty() { - let mut diagnostic = Diagnostic::new(PreferListBuiltin, Range::from(expr)); + let mut diagnostic = Diagnostic::new(ReimplementedListBuiltin, Range::from(expr)); if checker.patch(diagnostic.kind.rule()) { diagnostic.amend(Fix::replacement( "list".to_string(), diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap index 85cb34cdda..f33101674f 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - name: DupeClassFieldDefinitions + name: DuplicateClassFieldDefinition body: "Class field `name` is defined multiple times" suggestion: "Remove duplicate field definition for `name`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: DupeClassFieldDefinitions + name: DuplicateClassFieldDefinition body: "Class field `name` is defined multiple times" suggestion: "Remove duplicate field definition for `name`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: DupeClassFieldDefinitions + name: DuplicateClassFieldDefinition body: "Class field `bar` is defined multiple times" suggestion: "Remove duplicate field definition for `bar`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: DupeClassFieldDefinitions + name: DuplicateClassFieldDefinition body: "Class field `bar` is defined multiple times" suggestion: "Remove duplicate field definition for `bar`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap index 142e65f08c..0c1213690c 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `\"B\"`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `2`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `\"2\"`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `2.5`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `False`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `None`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferUniqueEnums + name: NonUniqueEnums body: "Enum contains duplicate value: `2`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap index f8da70a11e..70d696c91b 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - name: PreferListBuiltin + name: ReimplementedListBuiltin body: "Prefer `list` over useless lambda" suggestion: "Replace with `list`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 53 parent: ~ - kind: - name: PreferListBuiltin + name: ReimplementedListBuiltin body: "Prefer `list` over useless lambda" suggestion: "Replace with `list`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: PreferListBuiltin + name: ReimplementedListBuiltin body: "Prefer `list` over useless lambda" suggestion: "Replace with `list`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap index 0c6b04ab39..663b10d21f 100644 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap +++ b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pie/mod.rs expression: diagnostics --- - kind: - name: SingleStartsEndsWith + name: MultipleStartsEndsWith body: "Call `startswith` once with a `tuple`" suggestion: "Merge into a single `startswith` call" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 46 parent: ~ - kind: - name: SingleStartsEndsWith + name: MultipleStartsEndsWith body: "Call `endswith` once with a `tuple`" suggestion: "Merge into a single `endswith` call" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 42 parent: ~ - kind: - name: SingleStartsEndsWith + name: MultipleStartsEndsWith body: "Call `startswith` once with a `tuple`" suggestion: "Merge into a single `startswith` call" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 42 parent: ~ - kind: - name: SingleStartsEndsWith + name: MultipleStartsEndsWith body: "Call `startswith` once with a `tuple`" suggestion: "Merge into a single `startswith` call" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 44 parent: ~ - kind: - name: SingleStartsEndsWith + name: MultipleStartsEndsWith body: "Call `startswith` once with a `tuple`" suggestion: "Merge into a single `startswith` call" fixable: true diff --git a/crates/ruff/src/rules/flake8_print/mod.rs b/crates/ruff/src/rules/flake8_print/mod.rs index b1a620708c..6f77cffedc 100644 --- a/crates/ruff/src/rules/flake8_print/mod.rs +++ b/crates/ruff/src/rules/flake8_print/mod.rs @@ -13,8 +13,8 @@ mod tests { use crate::settings; use crate::test::test_path; - #[test_case(Rule::PrintFound, Path::new("T201.py"); "T201")] - #[test_case(Rule::PPrintFound, Path::new("T203.py"); "T203")] + #[test_case(Rule::Print, Path::new("T201.py"); "T201")] + #[test_case(Rule::PPrint, Path::new("T203.py"); "T203")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_print/rules/mod.rs b/crates/ruff/src/rules/flake8_print/rules/mod.rs index 879b765b5a..505d8967dc 100644 --- a/crates/ruff/src/rules/flake8_print/rules/mod.rs +++ b/crates/ruff/src/rules/flake8_print/rules/mod.rs @@ -1,3 +1,3 @@ -pub use print_call::{print_call, PPrintFound, PrintFound}; +pub use print_call::{print_call, PPrint, Print}; mod print_call; diff --git a/crates/ruff/src/rules/flake8_print/rules/print_call.rs b/crates/ruff/src/rules/flake8_print/rules/print_call.rs index 4bd201b4a3..aebee8abb0 100644 --- a/crates/ruff/src/rules/flake8_print/rules/print_call.rs +++ b/crates/ruff/src/rules/flake8_print/rules/print_call.rs @@ -9,9 +9,9 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct PrintFound; +pub struct Print; -impl Violation for PrintFound { +impl Violation for Print { #[derive_message_formats] fn message(&self) -> String { format!("`print` found") @@ -19,9 +19,9 @@ impl Violation for PrintFound { } #[violation] -pub struct PPrintFound; +pub struct PPrint; -impl Violation for PPrintFound { +impl Violation for PPrint { #[derive_message_formats] fn message(&self) -> String { format!("`pprint` found") @@ -54,11 +54,11 @@ pub fn print_call(checker: &mut Checker, func: &Expr, keywords: &[Keyword]) { } } } - Diagnostic::new(PrintFound, Range::from(func)) + Diagnostic::new(Print, Range::from(func)) } else if call_path.as_ref().map_or(false, |call_path| { *call_path.as_slice() == ["pprint", "pprint"] }) { - Diagnostic::new(PPrintFound, Range::from(func)) + Diagnostic::new(PPrint, Range::from(func)) } else { return; } diff --git a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap b/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap index 17d9c26d91..17c1879ad2 100644 --- a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap +++ b/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_print/mod.rs expression: diagnostics --- - kind: - name: PrintFound + name: Print body: "`print` found" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PrintFound + name: Print body: "`print` found" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PrintFound + name: Print body: "`print` found" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PrintFound + name: Print body: "`print` found" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap b/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap index 29f805376f..5458fbb96c 100644 --- a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap +++ b/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_print/mod.rs expression: diagnostics --- - kind: - name: PPrintFound + name: PPrint body: "`pprint` found" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PPrintFound + name: PPrint body: "`pprint` found" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pyi/mod.rs b/crates/ruff/src/rules/flake8_pyi/mod.rs index 2ee0ec97ba..701318a612 100644 --- a/crates/ruff/src/rules/flake8_pyi/mod.rs +++ b/crates/ruff/src/rules/flake8_pyi/mod.rs @@ -13,8 +13,8 @@ mod tests { use crate::settings; use crate::test::test_path; - #[test_case(Rule::PrefixTypeParams, Path::new("PYI001.pyi"))] - #[test_case(Rule::PrefixTypeParams, Path::new("PYI001.py"))] + #[test_case(Rule::UnprefixedTypeParam, Path::new("PYI001.pyi"))] + #[test_case(Rule::UnprefixedTypeParam, Path::new("PYI001.py"))] #[test_case(Rule::BadVersionInfoComparison, Path::new("PYI006.pyi"))] #[test_case(Rule::BadVersionInfoComparison, Path::new("PYI006.py"))] #[test_case(Rule::UnrecognizedPlatformCheck, Path::new("PYI007.pyi"))] @@ -25,10 +25,10 @@ mod tests { #[test_case(Rule::NonEmptyStubBody, Path::new("PYI010.pyi"))] #[test_case(Rule::PassStatementStubBody, Path::new("PYI009.py"))] #[test_case(Rule::PassStatementStubBody, Path::new("PYI009.pyi"))] - #[test_case(Rule::TypedArgumentSimpleDefaults, Path::new("PYI011.py"))] - #[test_case(Rule::TypedArgumentSimpleDefaults, Path::new("PYI011.pyi"))] - #[test_case(Rule::ArgumentSimpleDefaults, Path::new("PYI014.py"))] - #[test_case(Rule::ArgumentSimpleDefaults, Path::new("PYI014.pyi"))] + #[test_case(Rule::TypedArgumentDefaultInStub, Path::new("PYI011.py"))] + #[test_case(Rule::TypedArgumentDefaultInStub, Path::new("PYI011.pyi"))] + #[test_case(Rule::ArgumentDefaultInStub, Path::new("PYI014.py"))] + #[test_case(Rule::ArgumentDefaultInStub, Path::new("PYI014.pyi"))] #[test_case(Rule::DocstringInStub, Path::new("PYI021.py"))] #[test_case(Rule::DocstringInStub, Path::new("PYI021.pyi"))] #[test_case(Rule::TypeCommentInStub, Path::new("PYI033.py"))] diff --git a/crates/ruff/src/rules/flake8_pyi/rules/mod.rs b/crates/ruff/src/rules/flake8_pyi/rules/mod.rs index 9327b956b3..3073a37dec 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/mod.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/mod.rs @@ -2,10 +2,10 @@ pub use bad_version_info_comparison::{bad_version_info_comparison, BadVersionInf pub use docstring_in_stubs::{docstring_in_stubs, DocstringInStub}; pub use non_empty_stub_body::{non_empty_stub_body, NonEmptyStubBody}; pub use pass_statement_stub_body::{pass_statement_stub_body, PassStatementStubBody}; -pub use prefix_type_params::{prefix_type_params, PrefixTypeParams}; +pub use prefix_type_params::{prefix_type_params, UnprefixedTypeParam}; pub use simple_defaults::{ - argument_simple_defaults, typed_argument_simple_defaults, ArgumentSimpleDefaults, - TypedArgumentSimpleDefaults, + argument_simple_defaults, typed_argument_simple_defaults, ArgumentDefaultInStub, + TypedArgumentDefaultInStub, }; pub use type_comment_in_stub::{type_comment_in_stub, TypeCommentInStub}; pub use unrecognized_platform::{ diff --git a/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs b/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs index 1209b060db..8edd285fc2 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs @@ -47,14 +47,14 @@ impl fmt::Display for VarKind { /// _T = TypeVar("_T") /// ``` #[violation] -pub struct PrefixTypeParams { +pub struct UnprefixedTypeParam { pub kind: VarKind, } -impl Violation for PrefixTypeParams { +impl Violation for UnprefixedTypeParam { #[derive_message_formats] fn message(&self) -> String { - let PrefixTypeParams { kind } = self; + let UnprefixedTypeParam { kind } = self; format!("Name of private `{kind}` must start with `_`") } } @@ -85,7 +85,7 @@ pub fn prefix_type_params(checker: &mut Checker, value: &Expr, targets: &[Expr]) return; }; checker.diagnostics.push(Diagnostic::new( - PrefixTypeParams { kind }, + UnprefixedTypeParam { kind }, Range::from(value), )); } diff --git a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs b/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs index ba4ef5b062..3d534b3781 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs @@ -8,10 +8,10 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct TypedArgumentSimpleDefaults; +pub struct TypedArgumentDefaultInStub; /// PYI011 -impl AlwaysAutofixableViolation for TypedArgumentSimpleDefaults { +impl AlwaysAutofixableViolation for TypedArgumentDefaultInStub { #[derive_message_formats] fn message(&self) -> String { format!("Only simple default values allowed for typed arguments") @@ -23,10 +23,10 @@ impl AlwaysAutofixableViolation for TypedArgumentSimpleDefaults { } #[violation] -pub struct ArgumentSimpleDefaults; +pub struct ArgumentDefaultInStub; /// PYI014 -impl Violation for ArgumentSimpleDefaults { +impl Violation for ArgumentDefaultInStub { #[derive_message_formats] fn message(&self) -> String { format!("Only simple default values allowed for arguments") @@ -194,7 +194,7 @@ pub fn typed_argument_simple_defaults(checker: &mut Checker, args: &Arguments) { if arg.node.annotation.is_some() { if !is_valid_default_value_with_annotation(default, checker) { let mut diagnostic = - Diagnostic::new(TypedArgumentSimpleDefaults, Range::from(default)); + Diagnostic::new(TypedArgumentDefaultInStub, Range::from(default)); if checker.patch(diagnostic.kind.rule()) { diagnostic.amend(Fix::replacement( @@ -221,7 +221,7 @@ pub fn typed_argument_simple_defaults(checker: &mut Checker, args: &Arguments) { if kwarg.node.annotation.is_some() { if !is_valid_default_value_with_annotation(default, checker) { let mut diagnostic = - Diagnostic::new(TypedArgumentSimpleDefaults, Range::from(default)); + Diagnostic::new(TypedArgumentDefaultInStub, Range::from(default)); if checker.patch(diagnostic.kind.rule()) { diagnostic.amend(Fix::replacement( @@ -250,10 +250,9 @@ pub fn argument_simple_defaults(checker: &mut Checker, args: &Arguments) { { if arg.node.annotation.is_none() { if !is_valid_default_value_with_annotation(default, checker) { - checker.diagnostics.push(Diagnostic::new( - ArgumentSimpleDefaults, - Range::from(default), - )); + checker + .diagnostics + .push(Diagnostic::new(ArgumentDefaultInStub, Range::from(default))); } } } @@ -269,10 +268,9 @@ pub fn argument_simple_defaults(checker: &mut Checker, args: &Arguments) { { if kwarg.node.annotation.is_none() { if !is_valid_default_value_with_annotation(default, checker) { - checker.diagnostics.push(Diagnostic::new( - ArgumentSimpleDefaults, - Range::from(default), - )); + checker + .diagnostics + .push(Diagnostic::new(ArgumentDefaultInStub, Range::from(default))); } } } diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap index 979da78c65..cf8b4fcb0b 100644 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap +++ b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pyi/mod.rs expression: diagnostics --- - kind: - name: PrefixTypeParams + name: UnprefixedTypeParam body: "Name of private `TypeVar` must start with `_`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PrefixTypeParams + name: UnprefixedTypeParam body: "Name of private `TypeVarTuple` must start with `_`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PrefixTypeParams + name: UnprefixedTypeParam body: "Name of private `ParamSpec` must start with `_`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap index 81f1c12f5a..4b6a94efe3 100644 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap +++ b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pyi/mod.rs expression: diagnostics --- - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 23 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 11 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -203,7 +203,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -223,7 +223,7 @@ expression: diagnostics column: 10 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -243,7 +243,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -263,7 +263,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -283,7 +283,7 @@ expression: diagnostics column: 24 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true @@ -303,7 +303,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: TypedArgumentSimpleDefaults + name: TypedArgumentDefaultInStub body: Only simple default values allowed for typed arguments suggestion: "Replace default value by `...`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap index 62d69d0474..adbf6d1c85 100644 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap +++ b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pyi/mod.rs expression: diagnostics --- - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ArgumentSimpleDefaults + name: ArgumentDefaultInStub body: Only simple default values allowed for arguments suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/mod.rs b/crates/ruff/src/rules/flake8_pytest_style/mod.rs index 7a737ac7fb..9e6565b47c 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/mod.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/mod.rs @@ -18,9 +18,9 @@ mod tests { use super::settings::Settings; use super::types; - #[test_case(Rule::IncorrectFixtureParenthesesStyle, Path::new("PT001.py"), Settings::default(), "PT001_default"; "PT001_0")] + #[test_case(Rule::PytestFixtureIncorrectParenthesesStyle, Path::new("PT001.py"), Settings::default(), "PT001_default"; "PT001_0")] #[test_case( - Rule::IncorrectFixtureParenthesesStyle, + Rule::PytestFixtureIncorrectParenthesesStyle, Path::new("PT001.py"), Settings { fixture_parentheses: false, @@ -29,13 +29,13 @@ mod tests { "PT001_no_parentheses"; "PT001_1" )] - #[test_case(Rule::FixturePositionalArgs, Path::new("PT002.py"), Settings::default(), "PT002"; "PT002")] - #[test_case(Rule::ExtraneousScopeFunction, Path::new("PT003.py"), Settings::default(), "PT003"; "PT003")] - #[test_case(Rule::MissingFixtureNameUnderscore, Path::new("PT004.py"), Settings::default(), "PT004"; "PT004")] - #[test_case(Rule::IncorrectFixtureNameUnderscore, Path::new("PT005.py"), Settings::default(), "PT005"; "PT005")] - #[test_case(Rule::ParametrizeNamesWrongType, Path::new("PT006.py"), Settings::default(), "PT006_default"; "PT006_0")] + #[test_case(Rule::PytestFixturePositionalArgs, Path::new("PT002.py"), Settings::default(), "PT002"; "PT002")] + #[test_case(Rule::PytestExtraneousScopeFunction, Path::new("PT003.py"), Settings::default(), "PT003"; "PT003")] + #[test_case(Rule::PytestMissingFixtureNameUnderscore, Path::new("PT004.py"), Settings::default(), "PT004"; "PT004")] + #[test_case(Rule::PytestIncorrectFixtureNameUnderscore, Path::new("PT005.py"), Settings::default(), "PT005"; "PT005")] + #[test_case(Rule::PytestParametrizeNamesWrongType, Path::new("PT006.py"), Settings::default(), "PT006_default"; "PT006_0")] #[test_case( - Rule::ParametrizeNamesWrongType, + Rule::PytestParametrizeNamesWrongType, Path::new("PT006.py"), Settings { parametrize_names_type: types::ParametrizeNameType::Csv, @@ -45,7 +45,7 @@ mod tests { "PT006_1" )] #[test_case( - Rule::ParametrizeNamesWrongType, + Rule::PytestParametrizeNamesWrongType, Path::new("PT006.py"), Settings { parametrize_names_type: types::ParametrizeNameType::List, @@ -55,14 +55,14 @@ mod tests { "PT006_2" )] #[test_case( - Rule::ParametrizeValuesWrongType, + Rule::PytestParametrizeValuesWrongType, Path::new("PT007.py"), Settings::default(), "PT007_list_of_tuples"; "PT007_0" )] #[test_case( - Rule::ParametrizeValuesWrongType, + Rule::PytestParametrizeValuesWrongType, Path::new("PT007.py"), Settings { parametrize_values_type: types::ParametrizeValuesType::Tuple, @@ -72,7 +72,7 @@ mod tests { "PT007_1" )] #[test_case( - Rule::ParametrizeValuesWrongType, + Rule::PytestParametrizeValuesWrongType, Path::new("PT007.py"), Settings { parametrize_values_type: types::ParametrizeValuesType::Tuple, @@ -83,7 +83,7 @@ mod tests { "PT007_2" )] #[test_case( - Rule::ParametrizeValuesWrongType, + Rule::PytestParametrizeValuesWrongType, Path::new("PT007.py"), Settings { parametrize_values_row_type: types::ParametrizeValuesRowType::List, @@ -93,29 +93,29 @@ mod tests { "PT007_3" )] #[test_case( - Rule::PatchWithLambda, + Rule::PytestPatchWithLambda, Path::new("PT008.py"), Settings::default(), "PT008"; "PT008" )] #[test_case( - Rule::UnittestAssertion, + Rule::PytestUnittestAssertion, Path::new("PT009.py"), Settings::default(), "PT009"; "PT009" )] - #[test_case(Rule::RaisesWithoutException, Path::new("PT010.py"), Settings::default(), "PT010"; "PT0010")] + #[test_case(Rule::PytestRaisesWithoutException, Path::new("PT010.py"), Settings::default(), "PT010"; "PT0010")] #[test_case( - Rule::RaisesTooBroad, + Rule::PytestRaisesTooBroad, Path::new("PT011.py"), Settings::default(), "PT011_default"; "PT011_0" )] #[test_case( - Rule::RaisesTooBroad, + Rule::PytestRaisesTooBroad, Path::new("PT011.py"), Settings { raises_extend_require_match_for: vec!["ZeroDivisionError".to_string()], @@ -125,7 +125,7 @@ mod tests { "PT011_1" )] #[test_case( - Rule::RaisesTooBroad, + Rule::PytestRaisesTooBroad, Path::new("PT011.py"), Settings { raises_require_match_for: vec!["ZeroDivisionError".to_string()], @@ -135,84 +135,84 @@ mod tests { "PT011_2" )] #[test_case( - Rule::RaisesWithMultipleStatements, + Rule::PytestRaisesWithMultipleStatements, Path::new("PT012.py"), Settings::default(), "PT012"; "PT012" )] #[test_case( - Rule::IncorrectPytestImport, + Rule::PytestIncorrectPytestImport, Path::new("PT013.py"), Settings::default(), "PT013"; "PT013" )] #[test_case( - Rule::AssertAlwaysFalse, + Rule::PytestAssertAlwaysFalse, Path::new("PT015.py"), Settings::default(), "PT015"; "PT015" )] #[test_case( - Rule::FailWithoutMessage, + Rule::PytestFailWithoutMessage, Path::new("PT016.py"), Settings::default(), "PT016"; "PT016" )] #[test_case( - Rule::AssertInExcept, + Rule::PytestAssertInExcept, Path::new("PT017.py"), Settings::default(), "PT017"; "PT017" )] #[test_case( - Rule::CompositeAssertion, + Rule::PytestCompositeAssertion, Path::new("PT018.py"), Settings::default(), "PT018"; "PT018" )] #[test_case( - Rule::FixtureParamWithoutValue, + Rule::PytestFixtureParamWithoutValue, Path::new("PT019.py"), Settings::default(), "PT019"; "PT019" )] #[test_case( - Rule::DeprecatedYieldFixture, + Rule::PytestDeprecatedYieldFixture, Path::new("PT020.py"), Settings::default(), "PT020"; "PT020" )] #[test_case( - Rule::FixtureFinalizerCallback, + Rule::PytestFixtureFinalizerCallback, Path::new("PT021.py"), Settings::default(), "PT021"; "PT021" )] #[test_case( - Rule::UselessYieldFixture, + Rule::PytestUselessYieldFixture, Path::new("PT022.py"), Settings::default(), "PT022"; "PT022" )] #[test_case( - Rule::IncorrectMarkParenthesesStyle, + Rule::PytestIncorrectMarkParenthesesStyle, Path::new("PT023.py"), Settings::default(), "PT023_default"; "PT023_0" )] #[test_case( - Rule::IncorrectMarkParenthesesStyle, + Rule::PytestIncorrectMarkParenthesesStyle, Path::new("PT023.py"), Settings { mark_parentheses: false, @@ -222,21 +222,21 @@ mod tests { "PT023_1" )] #[test_case( - Rule::UnnecessaryAsyncioMarkOnFixture, + Rule::PytestUnnecessaryAsyncioMarkOnFixture, Path::new("PT024.py"), Settings::default(), "PT024"; "PT024" )] #[test_case( - Rule::ErroneousUseFixturesOnFixture, + Rule::PytestErroneousUseFixturesOnFixture, Path::new("PT025.py"), Settings::default(), "PT025"; "PT025" )] #[test_case( - Rule::UseFixturesWithoutParameters, + Rule::PytestUseFixturesWithoutParameters, Path::new("PT026.py"), Settings::default(), "PT026"; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs index 55a5c8f172..b427f6e4ec 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs @@ -54,11 +54,11 @@ use super::unittest_assert::UnittestAssert; /// assert not something_else /// ``` #[violation] -pub struct CompositeAssertion { +pub struct PytestCompositeAssertion { pub fixable: bool, } -impl Violation for CompositeAssertion { +impl Violation for PytestCompositeAssertion { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] @@ -73,14 +73,14 @@ impl Violation for CompositeAssertion { } #[violation] -pub struct AssertInExcept { +pub struct PytestAssertInExcept { pub name: String, } -impl Violation for AssertInExcept { +impl Violation for PytestAssertInExcept { #[derive_message_formats] fn message(&self) -> String { - let AssertInExcept { name } = self; + let PytestAssertInExcept { name } = self; format!( "Found assertion on exception `{name}` in `except` block, use `pytest.raises()` instead" ) @@ -88,9 +88,9 @@ impl Violation for AssertInExcept { } #[violation] -pub struct AssertAlwaysFalse; +pub struct PytestAssertAlwaysFalse; -impl Violation for AssertAlwaysFalse { +impl Violation for PytestAssertAlwaysFalse { #[derive_message_formats] fn message(&self) -> String { format!("Assertion always fails, replace with `pytest.fail()`") @@ -98,23 +98,23 @@ impl Violation for AssertAlwaysFalse { } #[violation] -pub struct UnittestAssertion { +pub struct PytestUnittestAssertion { pub assertion: String, pub fixable: bool, } -impl Violation for UnittestAssertion { +impl Violation for PytestUnittestAssertion { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] fn message(&self) -> String { - let UnittestAssertion { assertion, .. } = self; + let PytestUnittestAssertion { assertion, .. } = self; format!("Use a regular `assert` instead of unittest-style `{assertion}`") } fn autofix_title_formatter(&self) -> Option String> { self.fixable - .then_some(|UnittestAssertion { assertion, .. }| { + .then_some(|PytestUnittestAssertion { assertion, .. }| { format!("Replace `{assertion}(...)` with `assert ...`") }) } @@ -159,7 +159,7 @@ where if let Some(current_assert) = self.current_assert { if id.as_str() == self.exception_name { self.errors.push(Diagnostic::new( - AssertInExcept { + PytestAssertInExcept { name: id.to_string(), }, Range::from(current_assert), @@ -198,7 +198,7 @@ pub fn unittest_assertion( && matches!(checker.ctx.current_stmt().node, StmtKind::Expr { .. }) && !has_comments_in(Range::from(expr), checker.locator); let mut diagnostic = Diagnostic::new( - UnittestAssertion { + PytestUnittestAssertion { assertion: unittest_assert.to_string(), fixable, }, @@ -225,7 +225,7 @@ pub fn unittest_assertion( /// PT015 pub fn assert_falsy(stmt: &Stmt, test: &Expr) -> Option { if is_falsy_constant(test) { - Some(Diagnostic::new(AssertAlwaysFalse, Range::from(stmt))) + Some(Diagnostic::new(PytestAssertAlwaysFalse, Range::from(stmt))) } else { None } @@ -432,7 +432,8 @@ pub fn composite_condition(checker: &mut Checker, stmt: &Stmt, test: &Expr, msg: let fixable = matches!(composite, CompositionKind::Simple) && msg.is_none() && !has_comments_in(Range::from(stmt), checker.locator); - let mut diagnostic = Diagnostic::new(CompositeAssertion { fixable }, Range::from(stmt)); + let mut diagnostic = + Diagnostic::new(PytestCompositeAssertion { fixable }, Range::from(stmt)); if fixable && checker.patch(diagnostic.kind.rule()) { if let Ok(fix) = fix_composite_condition(stmt, checker.locator, checker.stylist) { diagnostic.amend(fix); diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs index d9f94bd052..722102d1eb 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs @@ -10,9 +10,9 @@ use crate::checkers::ast::Checker; use super::helpers::{is_empty_or_null_string, is_pytest_fail}; #[violation] -pub struct FailWithoutMessage; +pub struct PytestFailWithoutMessage; -impl Violation for FailWithoutMessage { +impl Violation for PytestFailWithoutMessage { #[derive_message_formats] fn message(&self) -> String { format!("No message passed to `pytest.fail()`") @@ -28,12 +28,12 @@ pub fn fail_call(checker: &mut Checker, func: &Expr, args: &[Expr], keywords: &[ if is_empty_or_null_string(msg) { checker .diagnostics - .push(Diagnostic::new(FailWithoutMessage, Range::from(func))); + .push(Diagnostic::new(PytestFailWithoutMessage, Range::from(func))); } } else { checker .diagnostics - .push(Diagnostic::new(FailWithoutMessage, Range::from(func))); + .push(Diagnostic::new(PytestFailWithoutMessage, Range::from(func))); } } } diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs index 666c60c5bf..8d45eefdb9 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs @@ -21,15 +21,15 @@ use super::helpers::{ }; #[violation] -pub struct IncorrectFixtureParenthesesStyle { +pub struct PytestFixtureIncorrectParenthesesStyle { pub expected_parens: String, pub actual_parens: String, } -impl AlwaysAutofixableViolation for IncorrectFixtureParenthesesStyle { +impl AlwaysAutofixableViolation for PytestFixtureIncorrectParenthesesStyle { #[derive_message_formats] fn message(&self) -> String { - let IncorrectFixtureParenthesesStyle { + let PytestFixtureIncorrectParenthesesStyle { expected_parens, actual_parens, } = self; @@ -42,22 +42,22 @@ impl AlwaysAutofixableViolation for IncorrectFixtureParenthesesStyle { } #[violation] -pub struct FixturePositionalArgs { +pub struct PytestFixturePositionalArgs { pub function: String, } -impl Violation for FixturePositionalArgs { +impl Violation for PytestFixturePositionalArgs { #[derive_message_formats] fn message(&self) -> String { - let FixturePositionalArgs { function } = self; + let PytestFixturePositionalArgs { function } = self; format!("Configuration for fixture `{function}` specified via positional args, use kwargs") } } #[violation] -pub struct ExtraneousScopeFunction; +pub struct PytestExtraneousScopeFunction; -impl AlwaysAutofixableViolation for ExtraneousScopeFunction { +impl AlwaysAutofixableViolation for PytestExtraneousScopeFunction { #[derive_message_formats] fn message(&self) -> String { format!("`scope='function'` is implied in `@pytest.fixture()`") @@ -69,40 +69,40 @@ impl AlwaysAutofixableViolation for ExtraneousScopeFunction { } #[violation] -pub struct MissingFixtureNameUnderscore { +pub struct PytestMissingFixtureNameUnderscore { pub function: String, } -impl Violation for MissingFixtureNameUnderscore { +impl Violation for PytestMissingFixtureNameUnderscore { #[derive_message_formats] fn message(&self) -> String { - let MissingFixtureNameUnderscore { function } = self; + let PytestMissingFixtureNameUnderscore { function } = self; format!("Fixture `{function}` does not return anything, add leading underscore") } } #[violation] -pub struct IncorrectFixtureNameUnderscore { +pub struct PytestIncorrectFixtureNameUnderscore { pub function: String, } -impl Violation for IncorrectFixtureNameUnderscore { +impl Violation for PytestIncorrectFixtureNameUnderscore { #[derive_message_formats] fn message(&self) -> String { - let IncorrectFixtureNameUnderscore { function } = self; + let PytestIncorrectFixtureNameUnderscore { function } = self; format!("Fixture `{function}` returns a value, remove leading underscore") } } #[violation] -pub struct FixtureParamWithoutValue { +pub struct PytestFixtureParamWithoutValue { pub name: String, } -impl Violation for FixtureParamWithoutValue { +impl Violation for PytestFixtureParamWithoutValue { #[derive_message_formats] fn message(&self) -> String { - let FixtureParamWithoutValue { name } = self; + let PytestFixtureParamWithoutValue { name } = self; format!( "Fixture `{name}` without value is injected as parameter, use \ `@pytest.mark.usefixtures` instead" @@ -111,9 +111,9 @@ impl Violation for FixtureParamWithoutValue { } #[violation] -pub struct DeprecatedYieldFixture; +pub struct PytestDeprecatedYieldFixture; -impl Violation for DeprecatedYieldFixture { +impl Violation for PytestDeprecatedYieldFixture { #[derive_message_formats] fn message(&self) -> String { format!("`@pytest.yield_fixture` is deprecated, use `@pytest.fixture`") @@ -121,9 +121,9 @@ impl Violation for DeprecatedYieldFixture { } #[violation] -pub struct FixtureFinalizerCallback; +pub struct PytestFixtureFinalizerCallback; -impl Violation for FixtureFinalizerCallback { +impl Violation for PytestFixtureFinalizerCallback { #[derive_message_formats] fn message(&self) -> String { format!("Use `yield` instead of `request.addfinalizer`") @@ -131,14 +131,14 @@ impl Violation for FixtureFinalizerCallback { } #[violation] -pub struct UselessYieldFixture { +pub struct PytestUselessYieldFixture { pub name: String, } -impl AlwaysAutofixableViolation for UselessYieldFixture { +impl AlwaysAutofixableViolation for PytestUselessYieldFixture { #[derive_message_formats] fn message(&self) -> String { - let UselessYieldFixture { name } = self; + let PytestUselessYieldFixture { name } = self; format!("No teardown in fixture `{name}`, use `return` instead of `yield`") } @@ -148,9 +148,9 @@ impl AlwaysAutofixableViolation for UselessYieldFixture { } #[violation] -pub struct ErroneousUseFixturesOnFixture; +pub struct PytestErroneousUseFixturesOnFixture; -impl AlwaysAutofixableViolation for ErroneousUseFixturesOnFixture { +impl AlwaysAutofixableViolation for PytestErroneousUseFixturesOnFixture { #[derive_message_formats] fn message(&self) -> String { format!("`pytest.mark.usefixtures` has no effect on fixtures") @@ -162,9 +162,9 @@ impl AlwaysAutofixableViolation for ErroneousUseFixturesOnFixture { } #[violation] -pub struct UnnecessaryAsyncioMarkOnFixture; +pub struct PytestUnnecessaryAsyncioMarkOnFixture; -impl AlwaysAutofixableViolation for UnnecessaryAsyncioMarkOnFixture { +impl AlwaysAutofixableViolation for PytestUnnecessaryAsyncioMarkOnFixture { #[derive_message_formats] fn message(&self) -> String { format!("`pytest.mark.asyncio` is unnecessary for fixtures") @@ -242,7 +242,7 @@ fn pytest_fixture_parentheses( actual: &str, ) { let mut diagnostic = Diagnostic::new( - IncorrectFixtureParenthesesStyle { + PytestFixtureIncorrectParenthesesStyle { expected_parens: preferred.to_string(), actual_parens: actual.to_string(), }, @@ -277,7 +277,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E if checker .settings .rules - .enabled(Rule::IncorrectFixtureParenthesesStyle) + .enabled(Rule::PytestFixtureIncorrectParenthesesStyle) && !checker.settings.flake8_pytest_style.fixture_parentheses && args.is_empty() && keywords.is_empty() @@ -287,9 +287,14 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E pytest_fixture_parentheses(checker, decorator, fix, "", "()"); } - if checker.settings.rules.enabled(Rule::FixturePositionalArgs) && !args.is_empty() { + if checker + .settings + .rules + .enabled(Rule::PytestFixturePositionalArgs) + && !args.is_empty() + { checker.diagnostics.push(Diagnostic::new( - FixturePositionalArgs { + PytestFixturePositionalArgs { function: func_name.to_string(), }, Range::from(decorator), @@ -299,7 +304,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E if checker .settings .rules - .enabled(Rule::ExtraneousScopeFunction) + .enabled(Rule::PytestExtraneousScopeFunction) { let scope_keyword = keywords .iter() @@ -307,8 +312,10 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E if let Some(scope_keyword) = scope_keyword { if keyword_is_literal(scope_keyword, "function") { - let mut diagnostic = - Diagnostic::new(ExtraneousScopeFunction, Range::from(scope_keyword)); + let mut diagnostic = Diagnostic::new( + PytestExtraneousScopeFunction, + Range::from(scope_keyword), + ); if checker.patch(diagnostic.kind.rule()) { match fix_extraneous_scope_function( checker.locator, @@ -333,7 +340,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E if checker .settings .rules - .enabled(Rule::IncorrectFixtureParenthesesStyle) + .enabled(Rule::PytestFixtureIncorrectParenthesesStyle) && checker.settings.flake8_pytest_style.fixture_parentheses { let fix = Fix::insertion("()".to_string(), decorator.end_location.unwrap()); @@ -354,12 +361,12 @@ fn check_fixture_returns(checker: &mut Checker, func: &Stmt, func_name: &str, bo if checker .settings .rules - .enabled(Rule::IncorrectFixtureNameUnderscore) + .enabled(Rule::PytestIncorrectFixtureNameUnderscore) && visitor.has_return_with_value && func_name.starts_with('_') { checker.diagnostics.push(Diagnostic::new( - IncorrectFixtureNameUnderscore { + PytestIncorrectFixtureNameUnderscore { function: func_name.to_string(), }, Range::from(func), @@ -367,26 +374,30 @@ fn check_fixture_returns(checker: &mut Checker, func: &Stmt, func_name: &str, bo } else if checker .settings .rules - .enabled(Rule::MissingFixtureNameUnderscore) + .enabled(Rule::PytestMissingFixtureNameUnderscore) && !visitor.has_return_with_value && !visitor.has_yield_from && !func_name.starts_with('_') { checker.diagnostics.push(Diagnostic::new( - MissingFixtureNameUnderscore { + PytestMissingFixtureNameUnderscore { function: func_name.to_string(), }, Range::from(func), )); } - if checker.settings.rules.enabled(Rule::UselessYieldFixture) { + if checker + .settings + .rules + .enabled(Rule::PytestUselessYieldFixture) + { if let Some(stmt) = body.last() { if let StmtKind::Expr { value, .. } = &stmt.node { if let ExprKind::Yield { .. } = value.node { if visitor.yield_statements.len() == 1 { let mut diagnostic = Diagnostic::new( - UselessYieldFixture { + PytestUselessYieldFixture { name: func_name.to_string(), }, Range::from(stmt), @@ -415,7 +426,7 @@ fn check_test_function_args(checker: &mut Checker, args: &Arguments) { let name = &arg.node.arg; if name.starts_with('_') { checker.diagnostics.push(Diagnostic::new( - FixtureParamWithoutValue { + PytestFixtureParamWithoutValue { name: name.to_string(), }, Range::from(arg), @@ -428,7 +439,7 @@ fn check_test_function_args(checker: &mut Checker, args: &Arguments) { fn check_fixture_decorator_name(checker: &mut Checker, decorator: &Expr) { if is_pytest_yield_fixture(decorator, checker) { checker.diagnostics.push(Diagnostic::new( - DeprecatedYieldFixture, + PytestDeprecatedYieldFixture, Range::from(decorator), )); } @@ -448,7 +459,7 @@ fn check_fixture_addfinalizer(checker: &mut Checker, args: &Arguments, body: &[S if let Some(addfinalizer) = visitor.addfinalizer_call { checker.diagnostics.push(Diagnostic::new( - FixtureFinalizerCallback, + PytestFixtureFinalizerCallback, Range::from(addfinalizer), )); } @@ -462,11 +473,11 @@ fn check_fixture_marks(checker: &mut Checker, decorators: &[Expr]) { if checker .settings .rules - .enabled(Rule::UnnecessaryAsyncioMarkOnFixture) + .enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture) { if name == "asyncio" { let mut diagnostic = - Diagnostic::new(UnnecessaryAsyncioMarkOnFixture, Range::from(mark)); + Diagnostic::new(PytestUnnecessaryAsyncioMarkOnFixture, Range::from(mark)); if checker.patch(diagnostic.kind.rule()) { let start = Location::new(mark.location.row(), 0); let end = Location::new(mark.end_location.unwrap().row() + 1, 0); @@ -479,11 +490,11 @@ fn check_fixture_marks(checker: &mut Checker, decorators: &[Expr]) { if checker .settings .rules - .enabled(Rule::ErroneousUseFixturesOnFixture) + .enabled(Rule::PytestErroneousUseFixturesOnFixture) { if name == "usefixtures" { let mut diagnostic = - Diagnostic::new(ErroneousUseFixturesOnFixture, Range::from(mark)); + Diagnostic::new(PytestErroneousUseFixturesOnFixture, Range::from(mark)); if checker.patch(diagnostic.kind.rule()) { let start = Location::new(mark.location.row(), 0); let end = Location::new(mark.end_location.unwrap().row() + 1, 0); @@ -508,17 +519,23 @@ pub fn fixture( if checker .settings .rules - .enabled(Rule::IncorrectFixtureParenthesesStyle) - || checker.settings.rules.enabled(Rule::FixturePositionalArgs) + .enabled(Rule::PytestFixtureIncorrectParenthesesStyle) || checker .settings .rules - .enabled(Rule::ExtraneousScopeFunction) + .enabled(Rule::PytestFixturePositionalArgs) + || checker + .settings + .rules + .enabled(Rule::PytestExtraneousScopeFunction) { check_fixture_decorator(checker, func_name, decorator); } - if checker.settings.rules.enabled(Rule::DeprecatedYieldFixture) + if checker + .settings + .rules + .enabled(Rule::PytestDeprecatedYieldFixture) && checker.settings.flake8_pytest_style.fixture_parentheses { check_fixture_decorator_name(checker, decorator); @@ -527,12 +544,15 @@ pub fn fixture( if (checker .settings .rules - .enabled(Rule::MissingFixtureNameUnderscore) + .enabled(Rule::PytestMissingFixtureNameUnderscore) || checker .settings .rules - .enabled(Rule::IncorrectFixtureNameUnderscore) - || checker.settings.rules.enabled(Rule::UselessYieldFixture)) + .enabled(Rule::PytestIncorrectFixtureNameUnderscore) + || checker + .settings + .rules + .enabled(Rule::PytestUselessYieldFixture)) && !has_abstractmethod_decorator(decorators, checker) { check_fixture_returns(checker, func, func_name, body); @@ -541,7 +561,7 @@ pub fn fixture( if checker .settings .rules - .enabled(Rule::FixtureFinalizerCallback) + .enabled(Rule::PytestFixtureFinalizerCallback) { check_fixture_addfinalizer(checker, args, body); } @@ -549,11 +569,11 @@ pub fn fixture( if checker .settings .rules - .enabled(Rule::UnnecessaryAsyncioMarkOnFixture) + .enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture) || checker .settings .rules - .enabled(Rule::ErroneousUseFixturesOnFixture) + .enabled(Rule::PytestErroneousUseFixturesOnFixture) { check_fixture_marks(checker, decorators); } @@ -562,7 +582,7 @@ pub fn fixture( if checker .settings .rules - .enabled(Rule::FixtureParamWithoutValue) + .enabled(Rule::PytestFixtureParamWithoutValue) && func_name.starts_with("test_") { check_test_function_args(checker, args); diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs index 11aba8c030..c5dbad8959 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs @@ -5,9 +5,9 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::types::Range; #[violation] -pub struct IncorrectPytestImport; +pub struct PytestIncorrectPytestImport; -impl Violation for IncorrectPytestImport { +impl Violation for PytestIncorrectPytestImport { #[derive_message_formats] fn message(&self) -> String { format!("Found incorrect import of pytest, use simple `import pytest` instead") @@ -24,7 +24,7 @@ pub fn import(import_from: &Stmt, name: &str, asname: Option<&str>) -> Option String { - let IncorrectMarkParenthesesStyle { + let PytestIncorrectMarkParenthesesStyle { mark_name, expected_parens, actual_parens, @@ -36,9 +36,9 @@ impl AlwaysAutofixableViolation for IncorrectMarkParenthesesStyle { } #[violation] -pub struct UseFixturesWithoutParameters; +pub struct PytestUseFixturesWithoutParameters; -impl AlwaysAutofixableViolation for UseFixturesWithoutParameters { +impl AlwaysAutofixableViolation for PytestUseFixturesWithoutParameters { #[derive_message_formats] fn message(&self) -> String { format!("Useless `pytest.mark.usefixtures` without parameters") @@ -57,7 +57,7 @@ fn pytest_mark_parentheses( actual: &str, ) { let mut diagnostic = Diagnostic::new( - IncorrectMarkParenthesesStyle { + PytestIncorrectMarkParenthesesStyle { mark_name: get_mark_name(decorator).to_string(), expected_parens: preferred.to_string(), actual_parens: actual.to_string(), @@ -110,7 +110,8 @@ fn check_useless_usefixtures(checker: &mut Checker, decorator: &Expr) { } if !has_parameters { - let mut diagnostic = Diagnostic::new(UseFixturesWithoutParameters, Range::from(decorator)); + let mut diagnostic = + Diagnostic::new(PytestUseFixturesWithoutParameters, Range::from(decorator)); if checker.patch(diagnostic.kind.rule()) { let at_start = Location::new(decorator.location.row(), decorator.location.column() - 1); diagnostic.amend(Fix::deletion(at_start, decorator.end_location.unwrap())); @@ -123,11 +124,11 @@ pub fn marks(checker: &mut Checker, decorators: &[Expr]) { let enforce_parentheses = checker .settings .rules - .enabled(Rule::IncorrectMarkParenthesesStyle); + .enabled(Rule::PytestIncorrectMarkParenthesesStyle); let enforce_useless_usefixtures = checker .settings .rules - .enabled(Rule::UseFixturesWithoutParameters); + .enabled(Rule::PytestUseFixturesWithoutParameters); for mark in get_mark_decorators(decorators) { if enforce_parentheses { diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs index 60febc730f..6a8e227f35 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs @@ -1,21 +1,26 @@ pub use assertion::{ assert_falsy, assert_in_exception_handler, composite_condition, unittest_assertion, - AssertAlwaysFalse, AssertInExcept, CompositeAssertion, UnittestAssertion, + PytestAssertAlwaysFalse, PytestAssertInExcept, PytestCompositeAssertion, + PytestUnittestAssertion, }; -pub use fail::{fail_call, FailWithoutMessage}; +pub use fail::{fail_call, PytestFailWithoutMessage}; pub use fixture::{ - fixture, DeprecatedYieldFixture, ErroneousUseFixturesOnFixture, ExtraneousScopeFunction, - FixtureFinalizerCallback, FixtureParamWithoutValue, FixturePositionalArgs, - IncorrectFixtureNameUnderscore, IncorrectFixtureParenthesesStyle, MissingFixtureNameUnderscore, - UnnecessaryAsyncioMarkOnFixture, UselessYieldFixture, + fixture, PytestDeprecatedYieldFixture, PytestErroneousUseFixturesOnFixture, + PytestExtraneousScopeFunction, PytestFixtureFinalizerCallback, + PytestFixtureIncorrectParenthesesStyle, PytestFixtureParamWithoutValue, + PytestFixturePositionalArgs, PytestIncorrectFixtureNameUnderscore, + PytestMissingFixtureNameUnderscore, PytestUnnecessaryAsyncioMarkOnFixture, + PytestUselessYieldFixture, }; -pub use imports::{import, import_from, IncorrectPytestImport}; -pub use marks::{marks, IncorrectMarkParenthesesStyle, UseFixturesWithoutParameters}; -pub use parametrize::{parametrize, ParametrizeNamesWrongType, ParametrizeValuesWrongType}; -pub use patch::{patch_with_lambda, PatchWithLambda}; +pub use imports::{import, import_from, PytestIncorrectPytestImport}; +pub use marks::{marks, PytestIncorrectMarkParenthesesStyle, PytestUseFixturesWithoutParameters}; +pub use parametrize::{ + parametrize, PytestParametrizeNamesWrongType, PytestParametrizeValuesWrongType, +}; +pub use patch::{patch_with_lambda, PytestPatchWithLambda}; pub use raises::{ - complex_raises, raises_call, RaisesTooBroad, RaisesWithMultipleStatements, - RaisesWithoutException, + complex_raises, raises_call, PytestRaisesTooBroad, PytestRaisesWithMultipleStatements, + PytestRaisesWithoutException, }; mod assertion; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs index 2e4cb383c6..631d9e7aff 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -13,33 +13,33 @@ use super::super::types; use super::helpers::{is_pytest_parametrize, split_names}; #[violation] -pub struct ParametrizeNamesWrongType { +pub struct PytestParametrizeNamesWrongType { pub expected: types::ParametrizeNameType, } -impl AlwaysAutofixableViolation for ParametrizeNamesWrongType { +impl AlwaysAutofixableViolation for PytestParametrizeNamesWrongType { #[derive_message_formats] fn message(&self) -> String { - let ParametrizeNamesWrongType { expected } = self; + let PytestParametrizeNamesWrongType { expected } = self; format!("Wrong name(s) type in `@pytest.mark.parametrize`, expected `{expected}`") } fn autofix_title(&self) -> String { - let ParametrizeNamesWrongType { expected } = self; + let PytestParametrizeNamesWrongType { expected } = self; format!("Use a `{expected}` for parameter names") } } #[violation] -pub struct ParametrizeValuesWrongType { +pub struct PytestParametrizeValuesWrongType { pub values: types::ParametrizeValuesType, pub row: types::ParametrizeValuesRowType, } -impl Violation for ParametrizeValuesWrongType { +impl Violation for PytestParametrizeValuesWrongType { #[derive_message_formats] fn message(&self) -> String { - let ParametrizeValuesWrongType { values, row } = self; + let PytestParametrizeValuesWrongType { values, row } = self; format!("Wrong values type in `@pytest.mark.parametrize` expected `{values}` of `{row}`") } } @@ -94,7 +94,7 @@ fn check_names(checker: &mut Checker, expr: &Expr) { match names_type { types::ParametrizeNameType::Tuple => { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: names_type, }, Range::from(expr), @@ -127,7 +127,7 @@ fn check_names(checker: &mut Checker, expr: &Expr) { } types::ParametrizeNameType::List => { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: names_type, }, Range::from(expr), @@ -169,7 +169,7 @@ fn check_names(checker: &mut Checker, expr: &Expr) { types::ParametrizeNameType::Tuple => {} types::ParametrizeNameType::List => { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: names_type, }, Range::from(expr), @@ -191,7 +191,7 @@ fn check_names(checker: &mut Checker, expr: &Expr) { } types::ParametrizeNameType::Csv => { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: names_type, }, Range::from(expr), @@ -220,7 +220,7 @@ fn check_names(checker: &mut Checker, expr: &Expr) { types::ParametrizeNameType::List => {} types::ParametrizeNameType::Tuple => { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: names_type, }, Range::from(expr), @@ -245,7 +245,7 @@ fn check_names(checker: &mut Checker, expr: &Expr) { } types::ParametrizeNameType::Csv => { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: names_type, }, Range::from(expr), @@ -291,7 +291,7 @@ fn check_values(checker: &mut Checker, names: &Expr, values: &Expr) { ExprKind::List { elts, .. } => { if values_type != types::ParametrizeValuesType::List { checker.diagnostics.push(Diagnostic::new( - ParametrizeValuesWrongType { + PytestParametrizeValuesWrongType { values: values_type, row: values_row_type, }, @@ -305,7 +305,7 @@ fn check_values(checker: &mut Checker, names: &Expr, values: &Expr) { ExprKind::Tuple { elts, .. } => { if values_type != types::ParametrizeValuesType::Tuple { checker.diagnostics.push(Diagnostic::new( - ParametrizeValuesWrongType { + PytestParametrizeValuesWrongType { values: values_type, row: values_row_type, }, @@ -322,7 +322,7 @@ fn check_values(checker: &mut Checker, names: &Expr, values: &Expr) { fn handle_single_name(checker: &mut Checker, expr: &Expr, value: &Expr) { let mut diagnostic = Diagnostic::new( - ParametrizeNamesWrongType { + PytestParametrizeNamesWrongType { expected: types::ParametrizeNameType::Csv, }, Range::from(expr), @@ -349,7 +349,7 @@ fn handle_value_rows( ExprKind::Tuple { .. } => { if values_row_type != types::ParametrizeValuesRowType::Tuple { checker.diagnostics.push(Diagnostic::new( - ParametrizeValuesWrongType { + PytestParametrizeValuesWrongType { values: values_type, row: values_row_type, }, @@ -360,7 +360,7 @@ fn handle_value_rows( ExprKind::List { .. } => { if values_row_type != types::ParametrizeValuesRowType::List { checker.diagnostics.push(Diagnostic::new( - ParametrizeValuesWrongType { + PytestParametrizeValuesWrongType { values: values_type, row: values_row_type, }, @@ -380,7 +380,7 @@ pub fn parametrize(checker: &mut Checker, decorators: &[Expr]) { if checker .settings .rules - .enabled(Rule::ParametrizeNamesWrongType) + .enabled(Rule::PytestParametrizeNamesWrongType) { if let Some(names) = args.get(0) { check_names(checker, names); @@ -389,7 +389,7 @@ pub fn parametrize(checker: &mut Checker, decorators: &[Expr]) { if checker .settings .rules - .enabled(Rule::ParametrizeValuesWrongType) + .enabled(Rule::PytestParametrizeValuesWrongType) { if let Some(names) = args.get(0) { if let Some(values) = args.get(1) { diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs index b5491e28a7..fbb2bfeafc 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs @@ -9,9 +9,9 @@ use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; #[violation] -pub struct PatchWithLambda; +pub struct PytestPatchWithLambda; -impl Violation for PatchWithLambda { +impl Violation for PytestPatchWithLambda { #[derive_message_formats] fn message(&self) -> String { format!("Use `return_value=` instead of patching with `lambda`") @@ -82,7 +82,7 @@ fn check_patch_call( visitor.visit_expr(body); if !visitor.uses_args { - return Some(Diagnostic::new(PatchWithLambda, Range::from(call))); + return Some(Diagnostic::new(PytestPatchWithLambda, Range::from(call))); } } } diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs index c5b3dc3c3a..ab88368d17 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs @@ -11,9 +11,9 @@ use crate::registry::Rule; use super::helpers::is_empty_or_null_string; #[violation] -pub struct RaisesWithMultipleStatements; +pub struct PytestRaisesWithMultipleStatements; -impl Violation for RaisesWithMultipleStatements { +impl Violation for PytestRaisesWithMultipleStatements { #[derive_message_formats] fn message(&self) -> String { format!("`pytest.raises()` block should contain a single simple statement") @@ -21,14 +21,14 @@ impl Violation for RaisesWithMultipleStatements { } #[violation] -pub struct RaisesTooBroad { +pub struct PytestRaisesTooBroad { pub exception: String, } -impl Violation for RaisesTooBroad { +impl Violation for PytestRaisesTooBroad { #[derive_message_formats] fn message(&self) -> String { - let RaisesTooBroad { exception } = self; + let PytestRaisesTooBroad { exception } = self; format!( "`pytest.raises({exception})` is too broad, set the `match` parameter or use a more \ specific exception" @@ -37,9 +37,9 @@ impl Violation for RaisesTooBroad { } #[violation] -pub struct RaisesWithoutException; +pub struct PytestRaisesWithoutException; -impl Violation for RaisesWithoutException { +impl Violation for PytestRaisesWithoutException { #[derive_message_formats] fn message(&self) -> String { format!("set the expected exception in `pytest.raises()`") @@ -67,15 +67,20 @@ const fn is_non_trivial_with_body(body: &[Stmt]) -> bool { pub fn raises_call(checker: &mut Checker, func: &Expr, args: &[Expr], keywords: &[Keyword]) { if is_pytest_raises(checker, func) { - if checker.settings.rules.enabled(Rule::RaisesWithoutException) { + if checker + .settings + .rules + .enabled(Rule::PytestRaisesWithoutException) + { if args.is_empty() && keywords.is_empty() { - checker - .diagnostics - .push(Diagnostic::new(RaisesWithoutException, Range::from(func))); + checker.diagnostics.push(Diagnostic::new( + PytestRaisesWithoutException, + Range::from(func), + )); } } - if checker.settings.rules.enabled(Rule::RaisesTooBroad) { + if checker.settings.rules.enabled(Rule::PytestRaisesTooBroad) { let match_keyword = keywords .iter() .find(|kw| kw.node.arg == Some("match".to_string())); @@ -127,7 +132,7 @@ pub fn complex_raises(checker: &mut Checker, stmt: &Stmt, items: &[Withitem], bo if is_too_complex { checker.diagnostics.push(Diagnostic::new( - RaisesWithMultipleStatements, + PytestRaisesWithMultipleStatements, Range::from(stmt), )); } @@ -160,7 +165,7 @@ fn exception_needs_match(checker: &mut Checker, exception: &Expr) { }) { checker.diagnostics.push(Diagnostic::new( - RaisesTooBroad { + PytestRaisesTooBroad { exception: call_path, }, Range::from(exception), diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap index f8482ae96c..cd4a9bb0e2 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture()` over `@pytest.fixture`" suggestion: Add/remove parentheses fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture()` over `@pytest.fixture`" suggestion: Add/remove parentheses fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture()` over `@pytest.fixture`" suggestion: Add/remove parentheses fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap index f9f756695c..9fedc34125 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture` over `@pytest.fixture()`" suggestion: Add/remove parentheses fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 17 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture` over `@pytest.fixture()`" suggestion: Add/remove parentheses fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture` over `@pytest.fixture()`" suggestion: Add/remove parentheses fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 10 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture` over `@pytest.fixture()`" suggestion: Add/remove parentheses fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture` over `@pytest.fixture()`" suggestion: Add/remove parentheses fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 10 parent: ~ - kind: - name: IncorrectFixtureParenthesesStyle + name: PytestFixtureIncorrectParenthesesStyle body: "Use `@pytest.fixture` over `@pytest.fixture()`" suggestion: Add/remove parentheses fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap index 3c9f6c1e99..2c8c743fff 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: FixturePositionalArgs + name: PytestFixturePositionalArgs body: "Configuration for fixture `my_fixture` specified via positional args, use kwargs" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FixturePositionalArgs + name: PytestFixturePositionalArgs body: "Configuration for fixture `my_fixture` specified via positional args, use kwargs" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap index dc5917f276..a2390e08df 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 32 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 51 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 53 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 46 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: ExtraneousScopeFunction + name: PytestExtraneousScopeFunction body: "`scope='function'` is implied in `@pytest.fixture()`" suggestion: "Remove implied `scope` argument" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap index 9ef62ad148..a067775cf4 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: MissingFixtureNameUnderscore + name: PytestMissingFixtureNameUnderscore body: "Fixture `patch_something` does not return anything, add leading underscore" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: MissingFixtureNameUnderscore + name: PytestMissingFixtureNameUnderscore body: "Fixture `activate_context` does not return anything, add leading underscore" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap index a21b02b109..2e21e8b058 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: IncorrectFixtureNameUnderscore + name: PytestIncorrectFixtureNameUnderscore body: "Fixture `_my_fixture` returns a value, remove leading underscore" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IncorrectFixtureNameUnderscore + name: PytestIncorrectFixtureNameUnderscore body: "Fixture `_activate_context` returns a value, remove leading underscore" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IncorrectFixtureNameUnderscore + name: PytestIncorrectFixtureNameUnderscore body: "Fixture `_activate_context` returns a value, remove leading underscore" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap index 3c04de3109..5f4ef2dd97 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 36 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 35 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -96,7 +96,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap index 63488d0c25..6cb5e67345 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`" suggestion: "Use a `tuple` for parameter names" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 40 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`" suggestion: "Use a `tuple` for parameter names" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 56 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`" suggestion: "Use a `tuple` for parameter names" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 40 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 36 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`" suggestion: "Use a `tuple` for parameter names" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 35 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`" suggestion: "Use a `tuple` for parameter names" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 50 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`" suggestion: "Use a `tuple` for parameter names" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap index 1374f3f1d7..a7c68156f2 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`" suggestion: "Use a `list` for parameter names" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 40 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`" suggestion: "Use a `list` for parameter names" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 56 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`" suggestion: "Use a `list` for parameter names" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 40 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`" suggestion: "Use a `list` for parameter names" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 36 parent: ~ - kind: - name: ParametrizeNamesWrongType + name: PytestParametrizeNamesWrongType body: "Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`" suggestion: "Use a `csv` for parameter names" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap index a5316790e9..99ea8cf29b 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap index dcefb617e6..9898f62a89 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap index 4d2b8d8164..cca472b358 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap index f3f714136e..97bc32004d 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ParametrizeValuesWrongType + name: PytestParametrizeValuesWrongType body: "Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap index b2e97bf716..c631f1167a 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PatchWithLambda + name: PytestPatchWithLambda body: "Use `return_value=` instead of patching with `lambda`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap index a3cac9936d..17ba496c87 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 29 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 43 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 43 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -116,7 +116,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -129,7 +129,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -142,7 +142,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertTrue`" suggestion: "Replace `assertTrue(...)` with `assert ...`" fixable: true @@ -155,7 +155,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIsNotNone`" suggestion: ~ fixable: false @@ -168,7 +168,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIsNone`" suggestion: ~ fixable: false @@ -181,7 +181,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertEqual`" suggestion: ~ fixable: false @@ -194,7 +194,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertFalse`" suggestion: "Replace `assertFalse(...)` with `assert ...`" fixable: true @@ -214,7 +214,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertEqual`" suggestion: "Replace `assertEqual(...)` with `assert ...`" fixable: true @@ -234,7 +234,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertNotEqual`" suggestion: "Replace `assertNotEqual(...)` with `assert ...`" fixable: true @@ -254,7 +254,7 @@ expression: diagnostics column: 33 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertGreater`" suggestion: "Replace `assertGreater(...)` with `assert ...`" fixable: true @@ -274,7 +274,7 @@ expression: diagnostics column: 32 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertGreaterEqual`" suggestion: "Replace `assertGreaterEqual(...)` with `assert ...`" fixable: true @@ -294,7 +294,7 @@ expression: diagnostics column: 37 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertLess`" suggestion: "Replace `assertLess(...)` with `assert ...`" fixable: true @@ -314,7 +314,7 @@ expression: diagnostics column: 29 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertLessEqual`" suggestion: "Replace `assertLessEqual(...)` with `assert ...`" fixable: true @@ -334,7 +334,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIn`" suggestion: "Replace `assertIn(...)` with `assert ...`" fixable: true @@ -354,7 +354,7 @@ expression: diagnostics column: 32 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertNotIn`" suggestion: "Replace `assertNotIn(...)` with `assert ...`" fixable: true @@ -374,7 +374,7 @@ expression: diagnostics column: 35 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIsNone`" suggestion: "Replace `assertIsNone(...)` with `assert ...`" fixable: true @@ -394,7 +394,7 @@ expression: diagnostics column: 28 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIsNotNone`" suggestion: "Replace `assertIsNotNone(...)` with `assert ...`" fixable: true @@ -414,7 +414,7 @@ expression: diagnostics column: 31 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIs`" suggestion: "Replace `assertIs(...)` with `assert ...`" fixable: true @@ -434,7 +434,7 @@ expression: diagnostics column: 29 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIsNot`" suggestion: "Replace `assertIsNot(...)` with `assert ...`" fixable: true @@ -454,7 +454,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertIsInstance`" suggestion: "Replace `assertIsInstance(...)` with `assert ...`" fixable: true @@ -474,7 +474,7 @@ expression: diagnostics column: 37 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertNotIsInstance`" suggestion: "Replace `assertNotIsInstance(...)` with `assert ...`" fixable: true @@ -494,7 +494,7 @@ expression: diagnostics column: 40 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertRegex`" suggestion: "Replace `assertRegex(...)` with `assert ...`" fixable: true @@ -514,7 +514,7 @@ expression: diagnostics column: 39 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertNotRegex`" suggestion: "Replace `assertNotRegex(...)` with `assert ...`" fixable: true @@ -534,7 +534,7 @@ expression: diagnostics column: 42 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertRegexpMatches`" suggestion: "Replace `assertRegexpMatches(...)` with `assert ...`" fixable: true @@ -554,7 +554,7 @@ expression: diagnostics column: 47 parent: ~ - kind: - name: UnittestAssertion + name: PytestUnittestAssertion body: "Use a regular `assert` instead of unittest-style `assertNotRegex`" suggestion: "Replace `assertNotRegex(...)` with `assert ...`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap index d979b4eff7..6d29590254 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: RaisesWithoutException + name: PytestRaisesWithoutException body: "set the expected exception in `pytest.raises()`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap index 8fe071f8bc..e9d8b5fc45 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap index 190513ed8d..b0624bbf0b 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap index 62b1e83dda..01714c386a 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: RaisesTooBroad + name: PytestRaisesTooBroad body: "`pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap index 80a80cf43a..5b851a1c22 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: RaisesWithMultipleStatements + name: PytestRaisesWithMultipleStatements body: "`pytest.raises()` block should contain a single simple statement" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap index f8dd8f908b..d7072c8d8b 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: IncorrectPytestImport + name: PytestIncorrectPytestImport body: "Found incorrect import of pytest, use simple `import pytest` instead" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IncorrectPytestImport + name: PytestIncorrectPytestImport body: "Found incorrect import of pytest, use simple `import pytest` instead" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IncorrectPytestImport + name: PytestIncorrectPytestImport body: "Found incorrect import of pytest, use simple `import pytest` instead" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap index 48f05f2601..d4e3fd3a77 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: AssertAlwaysFalse + name: PytestAssertAlwaysFalse body: "Assertion always fails, replace with `pytest.fail()`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap index b1a68e3513..9cd8bf8e5c 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: FailWithoutMessage + name: PytestFailWithoutMessage body: "No message passed to `pytest.fail()`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FailWithoutMessage + name: PytestFailWithoutMessage body: "No message passed to `pytest.fail()`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FailWithoutMessage + name: PytestFailWithoutMessage body: "No message passed to `pytest.fail()`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FailWithoutMessage + name: PytestFailWithoutMessage body: "No message passed to `pytest.fail()`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FailWithoutMessage + name: PytestFailWithoutMessage body: "No message passed to `pytest.fail()`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap index f4ebfafed5..e8eee3056d 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: AssertInExcept + name: PytestAssertInExcept body: "Found assertion on exception `e` in `except` block, use `pytest.raises()` instead" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap index 72d3975712..6c43f75955 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true @@ -203,7 +203,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: ~ fixable: false @@ -216,7 +216,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: ~ fixable: false @@ -229,7 +229,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: ~ fixable: false @@ -242,7 +242,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: CompositeAssertion + name: PytestCompositeAssertion body: Assertion should be broken down into multiple parts suggestion: Break down assertion into multiple parts fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap index 2645392ce6..e558f647d9 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: FixtureParamWithoutValue + name: PytestFixtureParamWithoutValue body: "Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FixtureParamWithoutValue + name: PytestFixtureParamWithoutValue body: "Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap index 3cffad8624..6a11a6d3dc 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: DeprecatedYieldFixture + name: PytestDeprecatedYieldFixture body: "`@pytest.yield_fixture` is deprecated, use `@pytest.fixture`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: DeprecatedYieldFixture + name: PytestDeprecatedYieldFixture body: "`@pytest.yield_fixture` is deprecated, use `@pytest.fixture`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap index 58361edc62..5c5f123d52 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: FixtureFinalizerCallback + name: PytestFixtureFinalizerCallback body: "Use `yield` instead of `request.addfinalizer`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FixtureFinalizerCallback + name: PytestFixtureFinalizerCallback body: "Use `yield` instead of `request.addfinalizer`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap index 8e990231bc..d2341c9050 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: UselessYieldFixture + name: PytestUselessYieldFixture body: "No teardown in fixture `error`, use `return` instead of `yield`" suggestion: "Replace `yield` with `return`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap index b5323a1f62..619a4e58eb 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo()` over `@pytest.mark.foo`" suggestion: Add/remove parentheses fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 16 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo()` over `@pytest.mark.foo`" suggestion: Add/remove parentheses fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 16 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo()` over `@pytest.mark.foo`" suggestion: Add/remove parentheses fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo()` over `@pytest.mark.foo`" suggestion: Add/remove parentheses fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo()` over `@pytest.mark.foo`" suggestion: Add/remove parentheses fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap index 331723fdae..6749d8e444 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo` over `@pytest.mark.foo()`" suggestion: Add/remove parentheses fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo` over `@pytest.mark.foo()`" suggestion: Add/remove parentheses fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo` over `@pytest.mark.foo()`" suggestion: Add/remove parentheses fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo` over `@pytest.mark.foo()`" suggestion: Add/remove parentheses fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: IncorrectMarkParenthesesStyle + name: PytestIncorrectMarkParenthesesStyle body: "Use `@pytest.mark.foo` over `@pytest.mark.foo()`" suggestion: Add/remove parentheses fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap index 96de80ef64..262422e91a 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: UnnecessaryAsyncioMarkOnFixture + name: PytestUnnecessaryAsyncioMarkOnFixture body: "`pytest.mark.asyncio` is unnecessary for fixtures" suggestion: "Remove `pytest.mark.asyncio`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: UnnecessaryAsyncioMarkOnFixture + name: PytestUnnecessaryAsyncioMarkOnFixture body: "`pytest.mark.asyncio` is unnecessary for fixtures" suggestion: "Remove `pytest.mark.asyncio`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: UnnecessaryAsyncioMarkOnFixture + name: PytestUnnecessaryAsyncioMarkOnFixture body: "`pytest.mark.asyncio` is unnecessary for fixtures" suggestion: "Remove `pytest.mark.asyncio`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: UnnecessaryAsyncioMarkOnFixture + name: PytestUnnecessaryAsyncioMarkOnFixture body: "`pytest.mark.asyncio` is unnecessary for fixtures" suggestion: "Remove `pytest.mark.asyncio`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap index 5705b206d8..d56466a469 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: ErroneousUseFixturesOnFixture + name: PytestErroneousUseFixturesOnFixture body: "`pytest.mark.usefixtures` has no effect on fixtures" suggestion: "Remove `pytest.mark.usefixtures`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: ErroneousUseFixturesOnFixture + name: PytestErroneousUseFixturesOnFixture body: "`pytest.mark.usefixtures` has no effect on fixtures" suggestion: "Remove `pytest.mark.usefixtures`" fixable: true diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap index 41246b6e60..a7f4c9c666 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_pytest_style/mod.rs expression: diagnostics --- - kind: - name: UseFixturesWithoutParameters + name: PytestUseFixturesWithoutParameters body: "Useless `pytest.mark.usefixtures` without parameters" suggestion: "Remove `usefixtures` decorator or pass parameters" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 26 parent: ~ - kind: - name: UseFixturesWithoutParameters + name: PytestUseFixturesWithoutParameters body: "Useless `pytest.mark.usefixtures` without parameters" suggestion: "Remove `usefixtures` decorator or pass parameters" fixable: true diff --git a/crates/ruff/src/rules/flake8_simplify/mod.rs b/crates/ruff/src/rules/flake8_simplify/mod.rs index 446c9bbd54..c66fb03e53 100644 --- a/crates/ruff/src/rules/flake8_simplify/mod.rs +++ b/crates/ruff/src/rules/flake8_simplify/mod.rs @@ -18,14 +18,14 @@ mod tests { #[test_case(Rule::NeedlessBool, Path::new("SIM103.py"); "SIM103")] #[test_case(Rule::UseContextlibSuppress, Path::new("SIM105.py"); "SIM105")] #[test_case(Rule::ReturnInTryExceptFinally, Path::new("SIM107.py"); "SIM107")] - #[test_case(Rule::UseTernaryOperator, Path::new("SIM108.py"); "SIM108")] + #[test_case(Rule::IfElseBlockInsteadOfIfExp, Path::new("SIM108.py"); "SIM108")] #[test_case(Rule::CompareWithTuple, Path::new("SIM109.py"); "SIM109")] #[test_case(Rule::ReimplementedBuiltin, Path::new("SIM110.py"); "SIM110")] #[test_case(Rule::ReimplementedBuiltin, Path::new("SIM111.py"); "SIM111")] - #[test_case(Rule::UseCapitalEnvironmentVariables, Path::new("SIM112.py"); "SIM112")] + #[test_case(Rule::UncapitalizedEnvironmentVariables, Path::new("SIM112.py"); "SIM112")] #[test_case(Rule::OpenFileWithContextHandler, Path::new("SIM115.py"); "SIM115")] #[test_case(Rule::MultipleWithStatements, Path::new("SIM117.py"); "SIM117")] - #[test_case(Rule::KeyInDict, Path::new("SIM118.py"); "SIM118")] + #[test_case(Rule::InDictKeys, Path::new("SIM118.py"); "SIM118")] #[test_case(Rule::NegateEqualOp, Path::new("SIM201.py"); "SIM201")] #[test_case(Rule::NegateNotEqualOp, Path::new("SIM202.py"); "SIM202")] #[test_case(Rule::DoubleNegation, Path::new("SIM208.py"); "SIM208")] @@ -37,8 +37,8 @@ mod tests { #[test_case(Rule::ExprOrTrue, Path::new("SIM222.py"); "SIM222")] #[test_case(Rule::ExprAndFalse, Path::new("SIM223.py"); "SIM223")] #[test_case(Rule::YodaConditions, Path::new("SIM300.py"); "SIM300")] - #[test_case(Rule::DictGetWithDefault, Path::new("SIM401.py"); "SIM401")] - #[test_case(Rule::ManualDictLookup, Path::new("SIM116.py"); "SIM116")] + #[test_case(Rule::IfElseBlockInsteadOfDictGet, Path::new("SIM401.py"); "SIM401")] + #[test_case(Rule::IfElseBlockInsteadOfDictLookup, Path::new("SIM116.py"); "SIM116")] #[test_case(Rule::IfWithSameArms, Path::new("SIM114.py"); "SIM114")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs index 2de0eb345f..2228c00bd5 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs @@ -9,20 +9,20 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct UseCapitalEnvironmentVariables { +pub struct UncapitalizedEnvironmentVariables { pub expected: String, pub original: String, } -impl AlwaysAutofixableViolation for UseCapitalEnvironmentVariables { +impl AlwaysAutofixableViolation for UncapitalizedEnvironmentVariables { #[derive_message_formats] fn message(&self) -> String { - let UseCapitalEnvironmentVariables { expected, original } = self; + let UncapitalizedEnvironmentVariables { expected, original } = self; format!("Use capitalized environment variable `{expected}` instead of `{original}`") } fn autofix_title(&self) -> String { - let UseCapitalEnvironmentVariables { expected, original } = self; + let UncapitalizedEnvironmentVariables { expected, original } = self; format!("Replace `{original}` with `{expected}`") } } @@ -62,7 +62,7 @@ pub fn use_capital_environment_variables(checker: &mut Checker, expr: &Expr) { } let mut diagnostic = Diagnostic::new( - UseCapitalEnvironmentVariables { + UncapitalizedEnvironmentVariables { expected: capital_env_var.clone(), original: env_var.clone(), }, @@ -104,7 +104,7 @@ fn check_os_environ_subscript(checker: &mut Checker, expr: &Expr) { } let mut diagnostic = Diagnostic::new( - UseCapitalEnvironmentVariables { + UncapitalizedEnvironmentVariables { expected: capital_env_var.clone(), original: env_var.clone(), }, diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs index 3330d9bea7..d04a1097fb 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs @@ -96,9 +96,9 @@ impl Violation for NeedlessBool { /// return {1: "Hello", 2: "Goodbye"}.get(x, "Goodnight") /// ``` #[violation] -pub struct ManualDictLookup; +pub struct IfElseBlockInsteadOfDictLookup; -impl Violation for ManualDictLookup { +impl Violation for IfElseBlockInsteadOfDictLookup { #[derive_message_formats] fn message(&self) -> String { format!("Use a dictionary instead of consecutive `if` statements") @@ -106,23 +106,23 @@ impl Violation for ManualDictLookup { } #[violation] -pub struct UseTernaryOperator { +pub struct IfElseBlockInsteadOfIfExp { pub contents: String, pub fixable: bool, } -impl Violation for UseTernaryOperator { +impl Violation for IfElseBlockInsteadOfIfExp { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] fn message(&self) -> String { - let UseTernaryOperator { contents, .. } = self; + let IfElseBlockInsteadOfIfExp { contents, .. } = self; format!("Use ternary operator `{contents}` instead of `if`-`else`-block") } fn autofix_title_formatter(&self) -> Option String> { self.fixable - .then_some(|UseTernaryOperator { contents, .. }| { + .then_some(|IfElseBlockInsteadOfIfExp { contents, .. }| { format!("Replace `if`-`else`-block with `{contents}`") }) } @@ -159,23 +159,25 @@ impl Violation for IfWithSameArms { } #[violation] -pub struct DictGetWithDefault { +pub struct IfElseBlockInsteadOfDictGet { pub contents: String, pub fixable: bool, } -impl Violation for DictGetWithDefault { +impl Violation for IfElseBlockInsteadOfDictGet { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] fn message(&self) -> String { - let DictGetWithDefault { contents, .. } = self; + let IfElseBlockInsteadOfDictGet { contents, .. } = self; format!("Use `{contents}` instead of an `if` block") } fn autofix_title_formatter(&self) -> Option String> { self.fixable - .then_some(|DictGetWithDefault { contents, .. }| format!("Replace with `{contents}`")) + .then_some(|IfElseBlockInsteadOfDictGet { contents, .. }| { + format!("Replace with `{contents}`") + }) } } @@ -494,7 +496,7 @@ pub fn use_ternary_operator(checker: &mut Checker, stmt: &Stmt, parent: Option<& let fixable = !has_comments(stmt, checker.locator); let mut diagnostic = Diagnostic::new( - UseTernaryOperator { + IfElseBlockInsteadOfIfExp { contents: contents.clone(), fixable, }, @@ -724,9 +726,10 @@ pub fn manual_dict_lookup( return; } - checker - .diagnostics - .push(Diagnostic::new(ManualDictLookup, Range::from(stmt))); + checker.diagnostics.push(Diagnostic::new( + IfElseBlockInsteadOfDictLookup, + Range::from(stmt), + )); } /// SIM401 @@ -842,7 +845,7 @@ pub fn use_dict_get_with_default( let fixable = !has_comments(stmt, checker.locator); let mut diagnostic = Diagnostic::new( - DictGetWithDefault { + IfElseBlockInsteadOfDictGet { contents: contents.clone(), fixable, }, diff --git a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs b/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs index 365ef1fe53..6cdd2aa473 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs @@ -8,20 +8,20 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct KeyInDict { +pub struct InDictKeys { pub key: String, pub dict: String, } -impl AlwaysAutofixableViolation for KeyInDict { +impl AlwaysAutofixableViolation for InDictKeys { #[derive_message_formats] fn message(&self) -> String { - let KeyInDict { key, dict } = self; + let InDictKeys { key, dict } = self; format!("Use `{key} in {dict}` instead of `{key} in {dict}.keys()`") } fn autofix_title(&self) -> String { - let KeyInDict { key, dict } = self; + let InDictKeys { key, dict } = self; format!("Convert to `{key} in {dict}`") } } @@ -51,7 +51,7 @@ fn key_in_dict(checker: &mut Checker, left: &Expr, right: &Expr, range: Range) { let value_content = checker.locator.slice(value); let mut diagnostic = Diagnostic::new( - KeyInDict { + InDictKeys { key: left_content.to_string(), dict: value_content.to_string(), }, diff --git a/crates/ruff/src/rules/flake8_simplify/rules/mod.rs b/crates/ruff/src/rules/flake8_simplify/rules/mod.rs index 10b93323e8..2f6cff9b9a 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/mod.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/mod.rs @@ -3,11 +3,11 @@ pub use ast_bool_op::{ expr_or_not_expr, expr_or_true, CompareWithTuple, DuplicateIsinstanceCall, ExprAndFalse, ExprAndNotExpr, ExprOrNotExpr, ExprOrTrue, }; -pub use ast_expr::{use_capital_environment_variables, UseCapitalEnvironmentVariables}; +pub use ast_expr::{use_capital_environment_variables, UncapitalizedEnvironmentVariables}; pub use ast_if::{ if_with_same_arms, manual_dict_lookup, needless_bool, nested_if_statements, - use_dict_get_with_default, use_ternary_operator, CollapsibleIf, DictGetWithDefault, - IfWithSameArms, ManualDictLookup, NeedlessBool, UseTernaryOperator, + use_dict_get_with_default, use_ternary_operator, CollapsibleIf, IfElseBlockInsteadOfDictGet, + IfElseBlockInsteadOfDictLookup, IfElseBlockInsteadOfIfExp, IfWithSameArms, NeedlessBool, }; pub use ast_ifexp::{ explicit_false_true_in_ifexpr, explicit_true_false_in_ifexpr, twisted_arms_in_ifexpr, @@ -18,7 +18,7 @@ pub use ast_unary_op::{ NegateEqualOp, NegateNotEqualOp, }; pub use ast_with::{multiple_with_statements, MultipleWithStatements}; -pub use key_in_dict::{key_in_dict_compare, key_in_dict_for, KeyInDict}; +pub use key_in_dict::{key_in_dict_compare, key_in_dict_for, InDictKeys}; pub use open_file_with_context_handler::{ open_file_with_context_handler, OpenFileWithContextHandler, }; diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap index 04215fea38..382dad0840 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_simplify/mod.rs expression: diagnostics --- - kind: - name: UseTernaryOperator + name: IfElseBlockInsteadOfIfExp body: "Use ternary operator `b = c if a else d` instead of `if`-`else`-block" suggestion: "Replace `if`-`else`-block with `b = c if a else d`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: UseTernaryOperator + name: IfElseBlockInsteadOfIfExp body: "Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block" suggestion: ~ fixable: false @@ -36,7 +36,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UseTernaryOperator + name: IfElseBlockInsteadOfIfExp body: "Use ternary operator `b = cccccccccccccccccccccccccccccccccccc if a else ddddddddddddddddddddddddddddddddddddd` instead of `if`-`else`-block" suggestion: "Replace `if`-`else`-block with `b = cccccccccccccccccccccccccccccccccccc if a else ddddddddddddddddddddddddddddddddddddd`" fixable: true @@ -56,7 +56,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: UseTernaryOperator + name: IfElseBlockInsteadOfIfExp body: "Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block" suggestion: ~ fixable: false @@ -69,7 +69,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UseTernaryOperator + name: IfElseBlockInsteadOfIfExp body: "Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block" suggestion: ~ fixable: false @@ -82,7 +82,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UseTernaryOperator + name: IfElseBlockInsteadOfIfExp body: "Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap index 0a1ee784c2..7d9847a56e 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_simplify/mod.rs expression: diagnostics --- - kind: - name: UseCapitalEnvironmentVariables + name: UncapitalizedEnvironmentVariables body: "Use capitalized environment variable `FOO` instead of `foo`" suggestion: "Replace `foo` with `FOO`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 16 parent: ~ - kind: - name: UseCapitalEnvironmentVariables + name: UncapitalizedEnvironmentVariables body: "Use capitalized environment variable `FOO` instead of `foo`" suggestion: "Replace `foo` with `FOO`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: UseCapitalEnvironmentVariables + name: UncapitalizedEnvironmentVariables body: "Use capitalized environment variable `FOO` instead of `foo`" suggestion: "Replace `foo` with `FOO`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: UseCapitalEnvironmentVariables + name: UncapitalizedEnvironmentVariables body: "Use capitalized environment variable `FOO` instead of `foo`" suggestion: "Replace `foo` with `FOO`" fixable: true diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap index 142757ded4..59a6aa66ef 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_simplify/mod.rs expression: diagnostics --- - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ManualDictLookup + name: IfElseBlockInsteadOfDictLookup body: "Use a dictionary instead of consecutive `if` statements" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap index 7154643626..0986875eeb 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_simplify/mod.rs expression: diagnostics --- - kind: - name: KeyInDict + name: InDictKeys body: "Use `key in obj` instead of `key in obj.keys()`" suggestion: "Convert to `key in obj`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 17 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `foo[\"bar\"] in obj` instead of `foo[\"bar\"] in obj.keys()`" suggestion: "Convert to `foo[\"bar\"] in obj`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 24 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `foo['bar'] in obj` instead of `foo['bar'] in obj.keys()`" suggestion: "Convert to `foo['bar'] in obj`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 24 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `foo() in obj` instead of `foo() in obj.keys()`" suggestion: "Convert to `foo() in obj`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 19 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `key in obj` instead of `key in obj.keys()`" suggestion: "Convert to `key in obj`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `k in obj` instead of `k in obj.keys()`" suggestion: "Convert to `k in obj`" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `k in obj` instead of `k in obj.keys()`" suggestion: "Convert to `k in obj`" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `k in obj` instead of `k in obj.keys()`" suggestion: "Convert to `k in obj`" fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 25 parent: ~ - kind: - name: KeyInDict + name: InDictKeys body: "Use `k in obj` instead of `k in obj.keys()`" suggestion: "Convert to `k in obj`" fixable: true diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap index 7f34a32bab..ed3f19c8bf 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/flake8_simplify/mod.rs expression: diagnostics --- - kind: - name: DictGetWithDefault + name: IfElseBlockInsteadOfDictGet body: "Use `var = a_dict.get(key, \"default1\")` instead of an `if` block" suggestion: "Replace with `var = a_dict.get(key, \"default1\")`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: DictGetWithDefault + name: IfElseBlockInsteadOfDictGet body: "Use `var = a_dict.get(key, \"default2\")` instead of an `if` block" suggestion: "Replace with `var = a_dict.get(key, \"default2\")`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: DictGetWithDefault + name: IfElseBlockInsteadOfDictGet body: "Use `var = a_dict.get(key, val1 + val2)` instead of an `if` block" suggestion: "Replace with `var = a_dict.get(key, val1 + val2)`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: DictGetWithDefault + name: IfElseBlockInsteadOfDictGet body: "Use `var = a_dict.get(keys[idx], \"default\")` instead of an `if` block" suggestion: "Replace with `var = a_dict.get(keys[idx], \"default\")`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 19 parent: ~ - kind: - name: DictGetWithDefault + name: IfElseBlockInsteadOfDictGet body: "Use `var = dicts[idx].get(key, \"default\")` instead of an `if` block" suggestion: "Replace with `var = dicts[idx].get(key, \"default\")`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 19 parent: ~ - kind: - name: DictGetWithDefault + name: IfElseBlockInsteadOfDictGet body: "Use `vars[idx] = a_dict.get(key, \"default\")` instead of an `if` block" suggestion: "Replace with `vars[idx] = a_dict.get(key, \"default\")`" fixable: true diff --git a/crates/ruff/src/rules/pandas_vet/mod.rs b/crates/ruff/src/rules/pandas_vet/mod.rs index 5a37b8321e..749a8a0983 100644 --- a/crates/ruff/src/rules/pandas_vet/mod.rs +++ b/crates/ruff/src/rules/pandas_vet/mod.rs @@ -61,7 +61,7 @@ mod tests { import pandas as pd x = pd.DataFrame() x.drop(['a'], axis=1, inplace=True) - "#, &[Rule::UseOfInplaceArgument]; "PD002_fail")] + "#, &[Rule::PandasUseOfInplaceArgument]; "PD002_fail")] #[test_case(r#" import pandas as pd nas = pd.isna(val) @@ -69,7 +69,7 @@ mod tests { #[test_case(r#" import pandas as pd nulls = pd.isnull(val) - "#, &[Rule::UseOfDotIsNull]; "PD003_fail")] + "#, &[Rule::PandasUseOfDotIsNull]; "PD003_fail")] #[test_case(r#" import pandas as pd print('bah humbug') @@ -81,7 +81,7 @@ mod tests { #[test_case(r#" import pandas as pd not_nulls = pd.notnull(val) - "#, &[Rule::UseOfDotNotNull]; "PD004_fail")] + "#, &[Rule::PandasUseOfDotNotNull]; "PD004_fail")] #[test_case(r#" import pandas as pd x = pd.DataFrame() @@ -96,7 +96,7 @@ mod tests { import pandas as pd x = pd.DataFrame() y = x.ix[[0, 2], 'A'] - "#, &[Rule::UseOfDotIx]; "PD007_fail")] + "#, &[Rule::PandasUseOfDotIx]; "PD007_fail")] #[test_case(r#" import pandas as pd x = pd.DataFrame() @@ -106,7 +106,7 @@ mod tests { import pandas as pd x = pd.DataFrame() index = x.at[:, ['B', 'A']] - "#, &[Rule::UseOfDotAt]; "PD008_fail")] + "#, &[Rule::PandasUseOfDotAt]; "PD008_fail")] #[test_case(r#" import pandas as pd x = pd.DataFrame() @@ -116,7 +116,7 @@ mod tests { import pandas as pd x = pd.DataFrame() index = x.iat[:, 1:3] - "#, &[Rule::UseOfDotIat]; "PD009_fail")] + "#, &[Rule::PandasUseOfDotIat]; "PD009_fail")] #[test_case(r#" import pandas as pd x = pd.DataFrame() @@ -138,7 +138,7 @@ mod tests { columns='bar', values='baz' ) - "#, &[Rule::UseOfDotPivotOrUnstack]; "PD010_fail_pivot")] + "#, &[Rule::PandasUseOfDotPivotOrUnstack]; "PD010_fail_pivot")] #[test_case(r#" import pandas as pd x = pd.DataFrame() @@ -153,7 +153,7 @@ mod tests { import pandas as pd x = pd.DataFrame() result = x.values - "#, &[Rule::UseOfDotValues]; "PD011_fail_values")] + "#, &[Rule::PandasUseOfDotValues]; "PD011_fail_values")] #[test_case(r#" import pandas as pd x = pd.DataFrame() @@ -182,7 +182,7 @@ mod tests { #[test_case(r#" import pandas as pd employees = pd.read_table(input_file) - "#, &[Rule::UseOfDotReadTable]; "PD012_fail_read_table")] + "#, &[Rule::PandasUseOfDotReadTable]; "PD012_fail_read_table")] #[test_case(r#" import pandas as pd employees = read_table @@ -209,7 +209,7 @@ mod tests { import pandas as pd x = pd.DataFrame() y = x.stack(level=-1, dropna=True) - "#, &[Rule::UseOfDotStack]; "PD013_fail_stack")] + "#, &[Rule::PandasUseOfDotStack]; "PD013_fail_stack")] #[test_case(r#" import pandas as pd pd.stack( @@ -225,7 +225,7 @@ mod tests { x = pd.DataFrame() y = pd.DataFrame() pd.merge(x, y) - "#, &[Rule::UseOfPdMerge]; "PD015_fail_merge_on_pandas_object")] + "#, &[Rule::PandasUseOfPdMerge]; "PD015_fail_merge_on_pandas_object")] #[test_case( "pd.to_datetime(timestamp * 10 ** 9).strftime('%Y-%m-%d %H:%M:%S.%f')", &[]; @@ -246,12 +246,12 @@ mod tests { #[test_case(r#" import pandas as pd df = pd.DataFrame() - "#, &[Rule::DfIsABadVariableName]; "PD901_fail_df_var")] + "#, &[Rule::PandasDfVariableName]; "PD901_fail_df_var")] fn test_pandas_vet(code: &str, expected: &[Rule]) { rule_code(code, expected); } - #[test_case(Rule::UseOfInplaceArgument, Path::new("PD002.py"); "PD002")] + #[test_case(Rule::PandasUseOfInplaceArgument, Path::new("PD002.py"); "PD002")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs b/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs index 68c6d7a253..9db64e7949 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs @@ -5,9 +5,9 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::types::Range; #[violation] -pub struct DfIsABadVariableName; +pub struct PandasDfVariableName; -impl Violation for DfIsABadVariableName { +impl Violation for PandasDfVariableName { #[derive_message_formats] fn message(&self) -> String { format!("`df` is a bad variable name. Be kinder to your future self.") @@ -26,5 +26,5 @@ pub fn assignment_to_df(targets: &[Expr]) -> Option { if id != "df" { return None; } - Some(Diagnostic::new(DfIsABadVariableName, Range::from(target))) + Some(Diagnostic::new(PandasDfVariableName, Range::from(target))) } diff --git a/crates/ruff/src/rules/pandas_vet/rules/check_attr.rs b/crates/ruff/src/rules/pandas_vet/rules/check_attr.rs index fed2f5638d..25bd01a719 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/check_attr.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/check_attr.rs @@ -11,9 +11,9 @@ use crate::registry::Rule; use crate::rules::pandas_vet::helpers::is_dataframe_candidate; #[violation] -pub struct UseOfDotIx; +pub struct PandasUseOfDotIx; -impl Violation for UseOfDotIx { +impl Violation for PandasUseOfDotIx { #[derive_message_formats] fn message(&self) -> String { format!("`.ix` is deprecated; use more explicit `.loc` or `.iloc`") @@ -21,9 +21,9 @@ impl Violation for UseOfDotIx { } #[violation] -pub struct UseOfDotAt; +pub struct PandasUseOfDotAt; -impl Violation for UseOfDotAt { +impl Violation for PandasUseOfDotAt { #[derive_message_formats] fn message(&self) -> String { format!("Use `.loc` instead of `.at`. If speed is important, use numpy.") @@ -31,9 +31,9 @@ impl Violation for UseOfDotAt { } #[violation] -pub struct UseOfDotIat; +pub struct PandasUseOfDotIat; -impl Violation for UseOfDotIat { +impl Violation for PandasUseOfDotIat { #[derive_message_formats] fn message(&self) -> String { format!("Use `.iloc` instead of `.iat`. If speed is important, use numpy.") @@ -41,9 +41,9 @@ impl Violation for UseOfDotIat { } #[violation] -pub struct UseOfDotValues; +pub struct PandasUseOfDotValues; -impl Violation for UseOfDotValues { +impl Violation for PandasUseOfDotValues { #[derive_message_formats] fn message(&self) -> String { format!("Use `.to_numpy()` instead of `.values`") @@ -53,10 +53,10 @@ impl Violation for UseOfDotValues { pub fn check_attr(checker: &mut Checker, attr: &str, value: &Expr, attr_expr: &Expr) { let rules = &checker.settings.rules; let violation: DiagnosticKind = match attr { - "ix" if rules.enabled(Rule::UseOfDotIx) => UseOfDotIx.into(), - "at" if rules.enabled(Rule::UseOfDotAt) => UseOfDotAt.into(), - "iat" if rules.enabled(Rule::UseOfDotIat) => UseOfDotIat.into(), - "values" if rules.enabled(Rule::UseOfDotValues) => UseOfDotValues.into(), + "ix" if rules.enabled(Rule::PandasUseOfDotIx) => PandasUseOfDotIx.into(), + "at" if rules.enabled(Rule::PandasUseOfDotAt) => PandasUseOfDotAt.into(), + "iat" if rules.enabled(Rule::PandasUseOfDotIat) => PandasUseOfDotIat.into(), + "values" if rules.enabled(Rule::PandasUseOfDotValues) => PandasUseOfDotValues.into(), _ => return, }; diff --git a/crates/ruff/src/rules/pandas_vet/rules/check_call.rs b/crates/ruff/src/rules/pandas_vet/rules/check_call.rs index 0e894a4d94..6eccb2b000 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/check_call.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/check_call.rs @@ -11,9 +11,9 @@ use crate::registry::Rule; use crate::rules::pandas_vet::helpers::is_dataframe_candidate; #[violation] -pub struct UseOfDotIsNull; +pub struct PandasUseOfDotIsNull; -impl Violation for UseOfDotIsNull { +impl Violation for PandasUseOfDotIsNull { #[derive_message_formats] fn message(&self) -> String { format!("`.isna` is preferred to `.isnull`; functionality is equivalent") @@ -21,9 +21,9 @@ impl Violation for UseOfDotIsNull { } #[violation] -pub struct UseOfDotNotNull; +pub struct PandasUseOfDotNotNull; -impl Violation for UseOfDotNotNull { +impl Violation for PandasUseOfDotNotNull { #[derive_message_formats] fn message(&self) -> String { format!("`.notna` is preferred to `.notnull`; functionality is equivalent") @@ -31,9 +31,9 @@ impl Violation for UseOfDotNotNull { } #[violation] -pub struct UseOfDotPivotOrUnstack; +pub struct PandasUseOfDotPivotOrUnstack; -impl Violation for UseOfDotPivotOrUnstack { +impl Violation for PandasUseOfDotPivotOrUnstack { #[derive_message_formats] fn message(&self) -> String { format!( @@ -43,9 +43,9 @@ impl Violation for UseOfDotPivotOrUnstack { } #[violation] -pub struct UseOfDotReadTable; +pub struct PandasUseOfDotReadTable; -impl Violation for UseOfDotReadTable { +impl Violation for PandasUseOfDotReadTable { #[derive_message_formats] fn message(&self) -> String { format!("`.read_csv` is preferred to `.read_table`; provides same functionality") @@ -53,9 +53,9 @@ impl Violation for UseOfDotReadTable { } #[violation] -pub struct UseOfDotStack; +pub struct PandasUseOfDotStack; -impl Violation for UseOfDotStack { +impl Violation for PandasUseOfDotStack { #[derive_message_formats] fn message(&self) -> String { format!("`.melt` is preferred to `.stack`; provides same functionality") @@ -66,13 +66,15 @@ pub fn check_call(checker: &mut Checker, func: &Expr) { let rules = &checker.settings.rules; let ExprKind::Attribute { value, attr, .. } = &func.node else {return}; let violation: DiagnosticKind = match attr.as_str() { - "isnull" if rules.enabled(Rule::UseOfDotIsNull) => UseOfDotIsNull.into(), - "notnull" if rules.enabled(Rule::UseOfDotNotNull) => UseOfDotNotNull.into(), - "pivot" | "unstack" if rules.enabled(Rule::UseOfDotPivotOrUnstack) => { - UseOfDotPivotOrUnstack.into() + "isnull" if rules.enabled(Rule::PandasUseOfDotIsNull) => PandasUseOfDotIsNull.into(), + "notnull" if rules.enabled(Rule::PandasUseOfDotNotNull) => PandasUseOfDotNotNull.into(), + "pivot" | "unstack" if rules.enabled(Rule::PandasUseOfDotPivotOrUnstack) => { + PandasUseOfDotPivotOrUnstack.into() } - "read_table" if rules.enabled(Rule::UseOfDotReadTable) => UseOfDotReadTable.into(), - "stack" if rules.enabled(Rule::UseOfDotStack) => UseOfDotStack.into(), + "read_table" if rules.enabled(Rule::PandasUseOfDotReadTable) => { + PandasUseOfDotReadTable.into() + } + "stack" if rules.enabled(Rule::PandasUseOfDotStack) => PandasUseOfDotStack.into(), _ => return, }; diff --git a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs index c797d53c5f..e310d6ec69 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs @@ -33,9 +33,9 @@ use crate::rules::pandas_vet::fixes::fix_inplace_argument; /// ## References /// - [_Why You Should Probably Never Use pandas inplace=True_](https://towardsdatascience.com/why-you-should-probably-never-use-pandas-inplace-true-9f9f211849e4) #[violation] -pub struct UseOfInplaceArgument; +pub struct PandasUseOfInplaceArgument; -impl AlwaysAutofixableViolation for UseOfInplaceArgument { +impl AlwaysAutofixableViolation for PandasUseOfInplaceArgument { #[derive_message_formats] fn message(&self) -> String { format!("`inplace=True` should be avoided; it has inconsistent behavior") @@ -65,7 +65,8 @@ pub fn inplace_argument( _ => false, }; if is_true_literal { - let mut diagnostic = Diagnostic::new(UseOfInplaceArgument, Range::from(keyword)); + let mut diagnostic = + Diagnostic::new(PandasUseOfInplaceArgument, Range::from(keyword)); if checker.patch(diagnostic.kind.rule()) { if let Some(fix) = fix_inplace_argument( checker.locator, diff --git a/crates/ruff/src/rules/pandas_vet/rules/mod.rs b/crates/ruff/src/rules/pandas_vet/rules/mod.rs index 1d5792cd7a..975d13b0ac 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/mod.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/mod.rs @@ -1,11 +1,13 @@ -pub use assignment_to_df::{assignment_to_df, DfIsABadVariableName}; -pub use check_attr::{check_attr, UseOfDotAt, UseOfDotIat, UseOfDotIx, UseOfDotValues}; -pub use check_call::{ - check_call, UseOfDotIsNull, UseOfDotNotNull, UseOfDotPivotOrUnstack, UseOfDotReadTable, - UseOfDotStack, +pub use assignment_to_df::{assignment_to_df, PandasDfVariableName}; +pub use check_attr::{ + check_attr, PandasUseOfDotAt, PandasUseOfDotIat, PandasUseOfDotIx, PandasUseOfDotValues, }; -pub use inplace_argument::{inplace_argument, UseOfInplaceArgument}; -pub use pd_merge::{use_of_pd_merge, UseOfPdMerge}; +pub use check_call::{ + check_call, PandasUseOfDotIsNull, PandasUseOfDotNotNull, PandasUseOfDotPivotOrUnstack, + PandasUseOfDotReadTable, PandasUseOfDotStack, +}; +pub use inplace_argument::{inplace_argument, PandasUseOfInplaceArgument}; +pub use pd_merge::{use_of_pd_merge, PandasUseOfPdMerge}; pub mod assignment_to_df; pub mod check_attr; diff --git a/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs b/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs index 5e46796980..7e09c4aac2 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs @@ -5,9 +5,9 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::types::Range; #[violation] -pub struct UseOfPdMerge; +pub struct PandasUseOfPdMerge; -impl Violation for UseOfPdMerge { +impl Violation for PandasUseOfPdMerge { #[derive_message_formats] fn message(&self) -> String { format!( @@ -22,7 +22,7 @@ pub fn use_of_pd_merge(func: &Expr) -> Option { if let ExprKind::Attribute { attr, value, .. } = &func.node { if let ExprKind::Name { id, .. } = &value.node { if id == "pd" && attr == "merge" { - return Some(Diagnostic::new(UseOfPdMerge, Range::from(func))); + return Some(Diagnostic::new(PandasUseOfPdMerge, Range::from(func))); } } } diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap index 559681b056..1ba2ac2ce8 100644 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pandas_vet/mod.rs expression: diagnostics --- - kind: - name: UseOfInplaceArgument + name: PandasUseOfInplaceArgument body: "`inplace=True` should be avoided; it has inconsistent behavior" suggestion: "Assign to variable; remove `inplace` arg" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 35 parent: ~ - kind: - name: UseOfInplaceArgument + name: PandasUseOfInplaceArgument body: "`inplace=True` should be avoided; it has inconsistent behavior" suggestion: "Assign to variable; remove `inplace` arg" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 35 parent: ~ - kind: - name: UseOfInplaceArgument + name: PandasUseOfInplaceArgument body: "`inplace=True` should be avoided; it has inconsistent behavior" suggestion: "Assign to variable; remove `inplace` arg" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: UseOfInplaceArgument + name: PandasUseOfInplaceArgument body: "`inplace=True` should be avoided; it has inconsistent behavior" suggestion: "Assign to variable; remove `inplace` arg" fixable: true diff --git a/crates/ruff/src/rules/pycodestyle/mod.rs b/crates/ruff/src/rules/pycodestyle/mod.rs index 5f70e3d302..1ca3577880 100644 --- a/crates/ruff/src/rules/pycodestyle/mod.rs +++ b/crates/ruff/src/rules/pycodestyle/mod.rs @@ -26,7 +26,7 @@ mod tests { #[test_case(Rule::AmbiguousVariableName, Path::new("E741.py"))] #[test_case(Rule::LambdaAssignment, Path::new("E731.py"))] #[test_case(Rule::BareExcept, Path::new("E722.py"))] - #[test_case(Rule::BlankLineContainsWhitespace, Path::new("W29.py"))] + #[test_case(Rule::BlankLineWithWhitespace, Path::new("W29.py"))] #[test_case(Rule::InvalidEscapeSequence, Path::new("W605_0.py"))] #[test_case(Rule::InvalidEscapeSequence, Path::new("W605_1.py"))] #[test_case(Rule::LineTooLong, Path::new("E501.py"))] @@ -36,15 +36,15 @@ mod tests { #[test_case(Rule::MultipleImportsOnOneLine, Path::new("E40.py"))] #[test_case(Rule::MultipleStatementsOnOneLineColon, Path::new("E70.py"))] #[test_case(Rule::MultipleStatementsOnOneLineSemicolon, Path::new("E70.py"))] - #[test_case(Rule::NoNewLineAtEndOfFile, Path::new("W292_0.py"))] - #[test_case(Rule::NoNewLineAtEndOfFile, Path::new("W292_1.py"))] - #[test_case(Rule::NoNewLineAtEndOfFile, Path::new("W292_2.py"))] - #[test_case(Rule::NoNewLineAtEndOfFile, Path::new("W292_3.py"))] + #[test_case(Rule::MissingNewlineAtEndOfFile, Path::new("W292_0.py"))] + #[test_case(Rule::MissingNewlineAtEndOfFile, Path::new("W292_1.py"))] + #[test_case(Rule::MissingNewlineAtEndOfFile, Path::new("W292_2.py"))] + #[test_case(Rule::MissingNewlineAtEndOfFile, Path::new("W292_3.py"))] #[test_case(Rule::NoneComparison, Path::new("E711.py"))] #[test_case(Rule::NotInTest, Path::new("E713.py"))] #[test_case(Rule::NotIsTest, Path::new("E714.py"))] #[test_case(Rule::SyntaxError, Path::new("E999.py"))] - #[test_case(Rule::IndentationContainsTabs, Path::new("W19.py"))] + #[test_case(Rule::TabIndentation, Path::new("W19.py"))] #[test_case(Rule::TrailingWhitespace, Path::new("W29.py"))] #[test_case(Rule::TrueFalseComparison, Path::new("E712.py"))] #[test_case(Rule::TypeComparison, Path::new("E721.py"))] @@ -63,7 +63,7 @@ mod tests { fn w292_4() -> Result<()> { let diagnostics = test_path( Path::new("pycodestyle/W292_4.py"), - &settings::Settings::for_rule(Rule::NoNewLineAtEndOfFile), + &settings::Settings::for_rule(Rule::MissingNewlineAtEndOfFile), )?; assert_yaml_snapshot!( diff --git a/crates/ruff/src/rules/pycodestyle/rules/no_newline_at_end_of_file.rs b/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs similarity index 89% rename from crates/ruff/src/rules/pycodestyle/rules/no_newline_at_end_of_file.rs rename to crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs index 9609c37895..a5907adf41 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/no_newline_at_end_of_file.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs @@ -23,9 +23,9 @@ use ruff_python_ast::types::Range; /// spam(1)\n /// ``` #[violation] -pub struct NoNewLineAtEndOfFile; +pub struct MissingNewlineAtEndOfFile; -impl AlwaysAutofixableViolation for NoNewLineAtEndOfFile { +impl AlwaysAutofixableViolation for MissingNewlineAtEndOfFile { #[derive_message_formats] fn message(&self) -> String { format!("No newline at end of file") @@ -49,7 +49,7 @@ pub fn no_newline_at_end_of_file( // Both locations are at the end of the file (and thus the same). let location = Location::new(locator.count_lines(), line.len()); let mut diagnostic = - Diagnostic::new(NoNewLineAtEndOfFile, Range::new(location, location)); + Diagnostic::new(MissingNewlineAtEndOfFile, Range::new(location, location)); if autofix { diagnostic.amend(Fix::insertion(stylist.line_ending().to_string(), location)); } diff --git a/crates/ruff/src/rules/pycodestyle/rules/mod.rs b/crates/ruff/src/rules/pycodestyle/rules/mod.rs index c9da0f671e..f36347fa4c 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/mod.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/mod.rs @@ -21,11 +21,11 @@ pub use indentation::{ NoIndentedBlock, NoIndentedBlockComment, OverIndented, UnexpectedIndentation, UnexpectedIndentationComment, }; -pub use indentation_contains_tabs::{indentation_contains_tabs, IndentationContainsTabs}; pub use invalid_escape_sequence::{invalid_escape_sequence, InvalidEscapeSequence}; pub use lambda_assignment::{lambda_assignment, LambdaAssignment}; pub use line_too_long::{line_too_long, LineTooLong}; pub use literal_comparisons::{literal_comparisons, NoneComparison, TrueFalseComparison}; +pub use missing_newline_at_end_of_file::{no_newline_at_end_of_file, MissingNewlineAtEndOfFile}; pub use missing_whitespace::{missing_whitespace, MissingWhitespace}; pub use missing_whitespace_after_keyword::{ missing_whitespace_after_keyword, MissingWhitespaceAfterKeyword, @@ -36,15 +36,13 @@ pub use missing_whitespace_around_operator::{ MissingWhitespaceAroundOperator, }; pub use mixed_spaces_and_tabs::{mixed_spaces_and_tabs, MixedSpacesAndTabs}; -pub use no_newline_at_end_of_file::{no_newline_at_end_of_file, NoNewLineAtEndOfFile}; pub use not_tests::{not_tests, NotInTest, NotIsTest}; pub use space_around_operator::{ space_around_operator, MultipleSpacesAfterOperator, MultipleSpacesBeforeOperator, TabAfterOperator, TabBeforeOperator, }; -pub use trailing_whitespace::{ - trailing_whitespace, BlankLineContainsWhitespace, TrailingWhitespace, -}; +pub use tab_indentation::{tab_indentation, TabIndentation}; +pub use trailing_whitespace::{trailing_whitespace, BlankLineWithWhitespace, TrailingWhitespace}; pub use type_comparison::{type_comparison, TypeComparison}; pub use whitespace_around_keywords::{ whitespace_around_keywords, MultipleSpacesAfterKeyword, MultipleSpacesBeforeKeyword, @@ -70,18 +68,18 @@ mod errors; mod extraneous_whitespace; mod imports; mod indentation; -mod indentation_contains_tabs; mod invalid_escape_sequence; mod lambda_assignment; mod line_too_long; mod literal_comparisons; +mod missing_newline_at_end_of_file; mod missing_whitespace; mod missing_whitespace_after_keyword; mod missing_whitespace_around_operator; mod mixed_spaces_and_tabs; -mod no_newline_at_end_of_file; mod not_tests; mod space_around_operator; +mod tab_indentation; mod trailing_whitespace; mod type_comparison; mod whitespace_around_keywords; diff --git a/crates/ruff/src/rules/pycodestyle/rules/indentation_contains_tabs.rs b/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs similarity index 76% rename from crates/ruff/src/rules/pycodestyle/rules/indentation_contains_tabs.rs rename to crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs index 29fb9d104c..442fe588a7 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/indentation_contains_tabs.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs @@ -6,9 +6,9 @@ use ruff_python_ast::types::Range; use ruff_python_ast::whitespace::leading_space; #[violation] -pub struct IndentationContainsTabs; +pub struct TabIndentation; -impl Violation for IndentationContainsTabs { +impl Violation for TabIndentation { #[derive_message_formats] fn message(&self) -> String { format!("Indentation contains tabs") @@ -16,12 +16,12 @@ impl Violation for IndentationContainsTabs { } /// W191 -pub fn indentation_contains_tabs(lineno: usize, line: &str) -> Option { +pub fn tab_indentation(lineno: usize, line: &str) -> Option { let indent = leading_space(line); if indent.contains('\t') { Some(Diagnostic::new( - IndentationContainsTabs, + TabIndentation, Range::new( Location::new(lineno + 1, 0), Location::new(lineno + 1, indent.chars().count()), diff --git a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs index 635069bd56..bcefb28b7c 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs @@ -61,9 +61,9 @@ impl AlwaysAutofixableViolation for TrailingWhitespace { /// ## References /// - [PEP 8](https://peps.python.org/pep-0008/#other-recommendations) #[violation] -pub struct BlankLineContainsWhitespace; +pub struct BlankLineWithWhitespace; -impl AlwaysAutofixableViolation for BlankLineContainsWhitespace { +impl AlwaysAutofixableViolation for BlankLineWithWhitespace { #[derive_message_formats] fn message(&self) -> String { format!("Blank line contains whitespace") @@ -88,11 +88,11 @@ pub fn trailing_whitespace( let end = Location::new(lineno + 1, line_char_count); if whitespace_count == line_char_count { - if settings.rules.enabled(Rule::BlankLineContainsWhitespace) { + if settings.rules.enabled(Rule::BlankLineWithWhitespace) { let mut diagnostic = - Diagnostic::new(BlankLineContainsWhitespace, Range::new(start, end)); + Diagnostic::new(BlankLineWithWhitespace, Range::new(start, end)); if matches!(autofix, flags::Autofix::Enabled) - && settings.rules.should_fix(Rule::BlankLineContainsWhitespace) + && settings.rules.should_fix(Rule::BlankLineWithWhitespace) { diagnostic.amend(Fix::deletion(start, end)); } diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap index 65727ee37c..524dbc0fb5 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pycodestyle/mod.rs expression: diagnostics --- - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -224,7 +224,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -237,7 +237,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -250,7 +250,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -263,7 +263,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -276,7 +276,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -289,7 +289,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -302,7 +302,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -315,7 +315,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -328,7 +328,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -341,7 +341,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -354,7 +354,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -367,7 +367,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -380,7 +380,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -393,7 +393,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -406,7 +406,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -419,7 +419,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -432,7 +432,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -445,7 +445,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -458,7 +458,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -471,7 +471,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false @@ -484,7 +484,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: IndentationContainsTabs + name: TabIndentation body: Indentation contains tabs suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap index d213ac67c3..5ac46f4516 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pycodestyle/mod.rs expression: diagnostics --- - kind: - name: NoNewLineAtEndOfFile + name: MissingNewlineAtEndOfFile body: No newline at end of file suggestion: Add trailing newline fixable: true diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap index 4456d6890c..d24458869a 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pycodestyle/mod.rs expression: diagnostics --- - kind: - name: BlankLineContainsWhitespace + name: BlankLineWithWhitespace body: Blank line contains whitespace suggestion: Remove whitespace from blank line fixable: true diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap index 7f65408075..88cb696639 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pycodestyle/mod.rs expression: diagnostics --- - kind: - name: NoNewLineAtEndOfFile + name: MissingNewlineAtEndOfFile body: No newline at end of file suggestion: Add trailing newline fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/mod.rs b/crates/ruff/src/rules/pydocstyle/mod.rs index 85eec194a4..37b298c4fe 100644 --- a/crates/ruff/src/rules/pydocstyle/mod.rs +++ b/crates/ruff/src/rules/pydocstyle/mod.rs @@ -19,9 +19,9 @@ mod tests { use super::settings::{Convention, Settings}; #[test_case(Rule::BlankLineAfterLastSection, Path::new("sections.py"); "D413")] - #[test_case(Rule::BlankLineAfterSection, Path::new("sections.py"); "D410")] + #[test_case(Rule::NoBlankLineAfterSection, Path::new("sections.py"); "D410")] #[test_case(Rule::BlankLineAfterSummary, Path::new("D.py"); "D205")] - #[test_case(Rule::BlankLineBeforeSection, Path::new("sections.py"); "D411")] + #[test_case(Rule::NoBlankLineBeforeSection, Path::new("sections.py"); "D411")] #[test_case(Rule::CapitalizeSectionName, Path::new("sections.py"); "D405")] #[test_case(Rule::DashedUnderlineAfterSection, Path::new("sections.py"); "D407")] #[test_case(Rule::UndocumentedParam, Path::new("canonical_google_examples.py"); "D417_2")] @@ -33,35 +33,35 @@ mod tests { #[test_case(Rule::FirstLineCapitalized, Path::new("D.py"); "D403")] #[test_case(Rule::FitsOnOneLine, Path::new("D.py"); "D200")] #[test_case(Rule::IndentWithSpaces, Path::new("D.py"); "D206")] - #[test_case(Rule::MagicMethod, Path::new("D.py"); "D105")] + #[test_case(Rule::UndocumentedMagicMethod, Path::new("D.py"); "D105")] #[test_case(Rule::MultiLineSummaryFirstLine, Path::new("D.py"); "D212")] #[test_case(Rule::MultiLineSummarySecondLine, Path::new("D.py"); "D213")] #[test_case(Rule::NewLineAfterLastParagraph, Path::new("D.py"); "D209")] #[test_case(Rule::NewLineAfterSectionName, Path::new("sections.py"); "D406")] #[test_case(Rule::NoBlankLineAfterFunction, Path::new("D.py"); "D202_0")] #[test_case(Rule::NoBlankLineAfterFunction, Path::new("D202.py"); "D202_1")] - #[test_case(Rule::NoBlankLineBeforeClass, Path::new("D.py"); "D211")] + #[test_case(Rule::BlankLineBeforeClass, Path::new("D.py"); "D211")] #[test_case(Rule::NoBlankLineBeforeFunction, Path::new("D.py"); "D201")] - #[test_case(Rule::NoBlankLinesBetweenHeaderAndContent, Path::new("sections.py"); "D412")] - #[test_case(Rule::NoOverIndentation, Path::new("D.py"); "D208")] + #[test_case(Rule::BlankLinesBetweenHeaderAndContent, Path::new("sections.py"); "D412")] + #[test_case(Rule::OverIndentation, Path::new("D.py"); "D208")] #[test_case(Rule::NoSignature, Path::new("D.py"); "D402")] - #[test_case(Rule::NoSurroundingWhitespace, Path::new("D.py"); "D210")] + #[test_case(Rule::SurroundingWhitespace, Path::new("D.py"); "D210")] #[test_case(Rule::DocstringStartsWithThis, Path::new("D.py"); "D404")] - #[test_case(Rule::NoUnderIndentation, Path::new("D.py"); "D207")] + #[test_case(Rule::UnderIndentation, Path::new("D.py"); "D207")] #[test_case(Rule::EmptyDocstring, Path::new("D.py"); "D419")] #[test_case(Rule::EmptyDocstringSection, Path::new("sections.py"); "D414")] #[test_case(Rule::NonImperativeMood, Path::new("D401.py"); "D401")] #[test_case(Rule::OneBlankLineAfterClass, Path::new("D.py"); "D204")] #[test_case(Rule::OneBlankLineBeforeClass, Path::new("D.py"); "D203")] - #[test_case(Rule::PublicClass, Path::new("D.py"); "D101")] - #[test_case(Rule::PublicFunction, Path::new("D.py"); "D103")] - #[test_case(Rule::PublicInit, Path::new("D.py"); "D107")] - #[test_case(Rule::PublicMethod, Path::new("D.py"); "D102_0")] - #[test_case(Rule::PublicMethod, Path::new("setter.py"); "D102_1")] - #[test_case(Rule::PublicModule, Path::new("D.py"); "D100")] - #[test_case(Rule::PublicNestedClass, Path::new("D.py"); "D106")] - #[test_case(Rule::PublicPackage, Path::new("D.py"); "D104_0")] - #[test_case(Rule::PublicPackage, Path::new("D104/__init__.py"); "D104_1")] + #[test_case(Rule::UndocumentedPublicClass, Path::new("D.py"); "D101")] + #[test_case(Rule::UndocumentedPublicFunction, Path::new("D.py"); "D103")] + #[test_case(Rule::UndocumentedPublicInit, Path::new("D.py"); "D107")] + #[test_case(Rule::UndocumentedPublicMethod, Path::new("D.py"); "D102_0")] + #[test_case(Rule::UndocumentedPublicMethod, Path::new("setter.py"); "D102_1")] + #[test_case(Rule::UndocumentedPublicModule, Path::new("D.py"); "D100")] + #[test_case(Rule::UndocumentedPublicNestedClass, Path::new("D.py"); "D106")] + #[test_case(Rule::UndocumentedPublicPackage, Path::new("D.py"); "D104_0")] + #[test_case(Rule::UndocumentedPublicPackage, Path::new("D104/__init__.py"); "D104_1")] #[test_case(Rule::SectionNameEndsInColon, Path::new("D.py"); "D416")] #[test_case(Rule::SectionNotOverIndented, Path::new("sections.py"); "D214")] #[test_case(Rule::SectionUnderlineAfterName, Path::new("sections.py"); "D408")] diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs index 79a643b2f0..9f70c0b44f 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -41,11 +41,11 @@ impl AlwaysAutofixableViolation for OneBlankLineAfterClass { } #[violation] -pub struct NoBlankLineBeforeClass { +pub struct BlankLineBeforeClass { pub lines: usize, } -impl AlwaysAutofixableViolation for NoBlankLineBeforeClass { +impl AlwaysAutofixableViolation for BlankLineBeforeClass { #[derive_message_formats] fn message(&self) -> String { format!("No blank lines allowed before class docstring") @@ -66,7 +66,7 @@ pub fn blank_before_after_class(checker: &mut Checker, docstring: &Docstring) { .settings .rules .enabled(Rule::OneBlankLineBeforeClass) - || checker.settings.rules.enabled(Rule::NoBlankLineBeforeClass) + || checker.settings.rules.enabled(Rule::BlankLineBeforeClass) { let before = checker .locator @@ -78,10 +78,10 @@ pub fn blank_before_after_class(checker: &mut Checker, docstring: &Docstring) { .skip(1) .take_while(|line| line.trim().is_empty()) .count(); - if checker.settings.rules.enabled(Rule::NoBlankLineBeforeClass) { + if checker.settings.rules.enabled(Rule::BlankLineBeforeClass) { if blank_lines_before != 0 { let mut diagnostic = Diagnostic::new( - NoBlankLineBeforeClass { + BlankLineBeforeClass { lines: blank_lines_before, }, Range::from(docstring.expr), diff --git a/crates/ruff/src/rules/pydocstyle/rules/indent.rs b/crates/ruff/src/rules/pydocstyle/rules/indent.rs index 9e5509d446..1ba3e33cf0 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/indent.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/indent.rs @@ -21,9 +21,9 @@ impl Violation for IndentWithSpaces { } #[violation] -pub struct NoUnderIndentation; +pub struct UnderIndentation; -impl AlwaysAutofixableViolation for NoUnderIndentation { +impl AlwaysAutofixableViolation for UnderIndentation { #[derive_message_formats] fn message(&self) -> String { format!("Docstring is under-indented") @@ -35,9 +35,9 @@ impl AlwaysAutofixableViolation for NoUnderIndentation { } #[violation] -pub struct NoOverIndentation; +pub struct OverIndentation; -impl AlwaysAutofixableViolation for NoOverIndentation { +impl AlwaysAutofixableViolation for OverIndentation { #[derive_message_formats] fn message(&self) -> String { format!("Docstring is over-indented") @@ -80,14 +80,14 @@ pub fn indent(checker: &mut Checker, docstring: &Docstring) { // yet. has_seen_tab = has_seen_tab || line_indent.contains('\t'); - if checker.settings.rules.enabled(Rule::NoUnderIndentation) { + if checker.settings.rules.enabled(Rule::UnderIndentation) { // We report under-indentation on every line. This isn't great, but enables // autofix. if (i == lines.len() - 1 || !is_blank) && line_indent.len() < docstring.indentation.len() { let mut diagnostic = Diagnostic::new( - NoUnderIndentation, + UnderIndentation, Range::new( Location::new(docstring.expr.location.row() + i, 0), Location::new(docstring.expr.location.row() + i, 0), @@ -128,7 +128,7 @@ pub fn indent(checker: &mut Checker, docstring: &Docstring) { } } - if checker.settings.rules.enabled(Rule::NoOverIndentation) { + if checker.settings.rules.enabled(Rule::OverIndentation) { // If every line (except the last) is over-indented... if is_over_indented { for i in over_indented_lines { @@ -137,7 +137,7 @@ pub fn indent(checker: &mut Checker, docstring: &Docstring) { // We report over-indentation on every line. This isn't great, but // enables autofix. let mut diagnostic = Diagnostic::new( - NoOverIndentation, + OverIndentation, Range::new( Location::new(docstring.expr.location.row() + i, 0), Location::new(docstring.expr.location.row() + i, 0), @@ -161,7 +161,7 @@ pub fn indent(checker: &mut Checker, docstring: &Docstring) { let line_indent = whitespace::leading_space(lines[i]); if line_indent.len() > docstring.indentation.len() { let mut diagnostic = Diagnostic::new( - NoOverIndentation, + OverIndentation, Range::new( Location::new(docstring.expr.location.row() + i, 0), Location::new(docstring.expr.location.row() + i, 0), diff --git a/crates/ruff/src/rules/pydocstyle/rules/mod.rs b/crates/ruff/src/rules/pydocstyle/rules/mod.rs index 5eb8c45e35..88b6d9bcaa 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/mod.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/mod.rs @@ -1,8 +1,7 @@ pub use backslashes::{backslashes, EscapeSequenceInDocstring}; pub use blank_after_summary::{blank_after_summary, BlankLineAfterSummary}; pub use blank_before_after_class::{ - blank_before_after_class, NoBlankLineBeforeClass, OneBlankLineAfterClass, - OneBlankLineBeforeClass, + blank_before_after_class, BlankLineBeforeClass, OneBlankLineAfterClass, OneBlankLineBeforeClass, }; pub use blank_before_after_function::{ blank_before_after_function, NoBlankLineAfterFunction, NoBlankLineBeforeFunction, @@ -11,24 +10,25 @@ pub use capitalized::{capitalized, FirstLineCapitalized}; pub use ends_with_period::{ends_with_period, EndsInPeriod}; pub use ends_with_punctuation::{ends_with_punctuation, EndsInPunctuation}; pub use if_needed::{if_needed, OverloadWithDocstring}; -pub use indent::{indent, IndentWithSpaces, NoOverIndentation, NoUnderIndentation}; +pub use indent::{indent, IndentWithSpaces, OverIndentation, UnderIndentation}; pub use multi_line_summary_start::{ multi_line_summary_start, MultiLineSummaryFirstLine, MultiLineSummarySecondLine, }; pub use newline_after_last_paragraph::{newline_after_last_paragraph, NewLineAfterLastParagraph}; pub use no_signature::{no_signature, NoSignature}; -pub use no_surrounding_whitespace::{no_surrounding_whitespace, NoSurroundingWhitespace}; +pub use no_surrounding_whitespace::{no_surrounding_whitespace, SurroundingWhitespace}; pub use non_imperative_mood::{non_imperative_mood, NonImperativeMood}; pub use not_empty::{not_empty, EmptyDocstring}; pub use not_missing::{ - not_missing, MagicMethod, PublicClass, PublicFunction, PublicInit, PublicMethod, PublicModule, - PublicNestedClass, PublicPackage, + not_missing, UndocumentedMagicMethod, UndocumentedPublicClass, UndocumentedPublicFunction, + UndocumentedPublicInit, UndocumentedPublicMethod, UndocumentedPublicModule, + UndocumentedPublicNestedClass, UndocumentedPublicPackage, }; pub use one_liner::{one_liner, FitsOnOneLine}; pub use sections::{ - sections, BlankLineAfterLastSection, BlankLineAfterSection, BlankLineBeforeSection, - CapitalizeSectionName, DashedUnderlineAfterSection, EmptyDocstringSection, - NewLineAfterSectionName, NoBlankLinesBetweenHeaderAndContent, SectionNameEndsInColon, + sections, BlankLineAfterLastSection, BlankLinesBetweenHeaderAndContent, CapitalizeSectionName, + DashedUnderlineAfterSection, EmptyDocstringSection, NewLineAfterSectionName, + NoBlankLineAfterSection, NoBlankLineBeforeSection, SectionNameEndsInColon, SectionNotOverIndented, SectionUnderlineAfterName, SectionUnderlineMatchesSectionLength, SectionUnderlineNotOverIndented, UndocumentedParam, }; diff --git a/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs b/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs index c4743f77e3..2172f59b0b 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs @@ -10,9 +10,9 @@ use crate::message::Location; use crate::registry::AsRule; #[violation] -pub struct NoSurroundingWhitespace; +pub struct SurroundingWhitespace; -impl AlwaysAutofixableViolation for NoSurroundingWhitespace { +impl AlwaysAutofixableViolation for SurroundingWhitespace { #[derive_message_formats] fn message(&self) -> String { format!("No whitespaces allowed surrounding docstring text") @@ -39,7 +39,7 @@ pub fn no_surrounding_whitespace(checker: &mut Checker, docstring: &Docstring) { if line == trimmed { return; } - let mut diagnostic = Diagnostic::new(NoSurroundingWhitespace, Range::from(docstring.expr)); + let mut diagnostic = Diagnostic::new(SurroundingWhitespace, Range::from(docstring.expr)); if checker.patch(diagnostic.kind.rule()) { if let Some(pattern) = leading_quote(contents) { // If removing whitespace would lead to an invalid string of quote diff --git a/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs b/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs index c4e4798fa8..3b56ccb4e8 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs @@ -13,9 +13,9 @@ use crate::message::Location; use crate::registry::Rule; #[violation] -pub struct PublicModule; +pub struct UndocumentedPublicModule; -impl Violation for PublicModule { +impl Violation for UndocumentedPublicModule { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in public module") @@ -23,9 +23,9 @@ impl Violation for PublicModule { } #[violation] -pub struct PublicClass; +pub struct UndocumentedPublicClass; -impl Violation for PublicClass { +impl Violation for UndocumentedPublicClass { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in public class") @@ -33,9 +33,9 @@ impl Violation for PublicClass { } #[violation] -pub struct PublicMethod; +pub struct UndocumentedPublicMethod; -impl Violation for PublicMethod { +impl Violation for UndocumentedPublicMethod { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in public method") @@ -43,9 +43,9 @@ impl Violation for PublicMethod { } #[violation] -pub struct PublicFunction; +pub struct UndocumentedPublicFunction; -impl Violation for PublicFunction { +impl Violation for UndocumentedPublicFunction { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in public function") @@ -53,9 +53,9 @@ impl Violation for PublicFunction { } #[violation] -pub struct PublicPackage; +pub struct UndocumentedPublicPackage; -impl Violation for PublicPackage { +impl Violation for UndocumentedPublicPackage { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in public package") @@ -63,9 +63,9 @@ impl Violation for PublicPackage { } #[violation] -pub struct MagicMethod; +pub struct UndocumentedMagicMethod; -impl Violation for MagicMethod { +impl Violation for UndocumentedMagicMethod { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in magic method") @@ -73,9 +73,9 @@ impl Violation for MagicMethod { } #[violation] -pub struct PublicNestedClass; +pub struct UndocumentedPublicNestedClass; -impl Violation for PublicNestedClass { +impl Violation for UndocumentedPublicNestedClass { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in public nested class") @@ -83,9 +83,9 @@ impl Violation for PublicNestedClass { } #[violation] -pub struct PublicInit; +pub struct UndocumentedPublicInit; -impl Violation for PublicInit { +impl Violation for UndocumentedPublicInit { #[derive_message_formats] fn message(&self) -> String { format!("Missing docstring in `__init__`") @@ -104,36 +104,52 @@ pub fn not_missing( match definition.kind { DefinitionKind::Module => { - if checker.settings.rules.enabled(Rule::PublicModule) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicModule) + { checker.diagnostics.push(Diagnostic::new( - PublicModule, + UndocumentedPublicModule, Range::new(Location::new(1, 0), Location::new(1, 0)), )); } false } DefinitionKind::Package => { - if checker.settings.rules.enabled(Rule::PublicPackage) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicPackage) + { checker.diagnostics.push(Diagnostic::new( - PublicPackage, + UndocumentedPublicPackage, Range::new(Location::new(1, 0), Location::new(1, 0)), )); } false } DefinitionKind::Class(stmt) => { - if checker.settings.rules.enabled(Rule::PublicClass) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicClass) + { checker.diagnostics.push(Diagnostic::new( - PublicClass, + UndocumentedPublicClass, identifier_range(stmt, checker.locator), )); } false } DefinitionKind::NestedClass(stmt) => { - if checker.settings.rules.enabled(Rule::PublicNestedClass) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicNestedClass) + { checker.diagnostics.push(Diagnostic::new( - PublicNestedClass, + UndocumentedPublicNestedClass, identifier_range(stmt, checker.locator), )); } @@ -143,9 +159,13 @@ pub fn not_missing( if is_overload(&checker.ctx, cast::decorator_list(stmt)) { true } else { - if checker.settings.rules.enabled(Rule::PublicFunction) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicFunction) + { checker.diagnostics.push(Diagnostic::new( - PublicFunction, + UndocumentedPublicFunction, identifier_range(stmt, checker.locator), )); } @@ -158,33 +178,45 @@ pub fn not_missing( { true } else if is_init(cast::name(stmt)) { - if checker.settings.rules.enabled(Rule::PublicInit) { + if checker.settings.rules.enabled(Rule::UndocumentedPublicInit) { checker.diagnostics.push(Diagnostic::new( - PublicInit, + UndocumentedPublicInit, identifier_range(stmt, checker.locator), )); } true } else if is_new(cast::name(stmt)) || is_call(cast::name(stmt)) { - if checker.settings.rules.enabled(Rule::PublicMethod) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicMethod) + { checker.diagnostics.push(Diagnostic::new( - PublicMethod, + UndocumentedPublicMethod, identifier_range(stmt, checker.locator), )); } true } else if is_magic(cast::name(stmt)) { - if checker.settings.rules.enabled(Rule::MagicMethod) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedMagicMethod) + { checker.diagnostics.push(Diagnostic::new( - MagicMethod, + UndocumentedMagicMethod, identifier_range(stmt, checker.locator), )); } true } else { - if checker.settings.rules.enabled(Rule::PublicMethod) { + if checker + .settings + .rules + .enabled(Rule::UndocumentedPublicMethod) + { checker.diagnostics.push(Diagnostic::new( - PublicMethod, + UndocumentedPublicMethod, identifier_range(stmt, checker.locator), )); } diff --git a/crates/ruff/src/rules/pydocstyle/rules/sections.rs b/crates/ruff/src/rules/pydocstyle/rules/sections.rs index 95f579cb56..9ffe498631 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/sections.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/sections.rs @@ -148,37 +148,37 @@ impl AlwaysAutofixableViolation for SectionUnderlineMatchesSectionLength { } #[violation] -pub struct BlankLineAfterSection { +pub struct NoBlankLineAfterSection { pub name: String, } -impl AlwaysAutofixableViolation for BlankLineAfterSection { +impl AlwaysAutofixableViolation for NoBlankLineAfterSection { #[derive_message_formats] fn message(&self) -> String { - let BlankLineAfterSection { name } = self; + let NoBlankLineAfterSection { name } = self; format!("Missing blank line after section (\"{name}\")") } fn autofix_title(&self) -> String { - let BlankLineAfterSection { name } = self; + let NoBlankLineAfterSection { name } = self; format!("Add blank line after \"{name}\"") } } #[violation] -pub struct BlankLineBeforeSection { +pub struct NoBlankLineBeforeSection { pub name: String, } -impl AlwaysAutofixableViolation for BlankLineBeforeSection { +impl AlwaysAutofixableViolation for NoBlankLineBeforeSection { #[derive_message_formats] fn message(&self) -> String { - let BlankLineBeforeSection { name } = self; + let NoBlankLineBeforeSection { name } = self; format!("Missing blank line before section (\"{name}\")") } fn autofix_title(&self) -> String { - let BlankLineBeforeSection { name } = self; + let NoBlankLineBeforeSection { name } = self; format!("Add blank line before \"{name}\"") } } @@ -252,14 +252,14 @@ impl Violation for UndocumentedParam { } #[violation] -pub struct NoBlankLinesBetweenHeaderAndContent { +pub struct BlankLinesBetweenHeaderAndContent { pub name: String, } -impl AlwaysAutofixableViolation for NoBlankLinesBetweenHeaderAndContent { +impl AlwaysAutofixableViolation for BlankLinesBetweenHeaderAndContent { #[derive_message_formats] fn message(&self) -> String { - let NoBlankLinesBetweenHeaderAndContent { name } = self; + let BlankLinesBetweenHeaderAndContent { name } = self; format!("No blank lines allowed between a section header and its content (\"{name}\")") } @@ -537,10 +537,10 @@ fn blanks_and_section_underline( if checker .settings .rules - .enabled(Rule::NoBlankLinesBetweenHeaderAndContent) + .enabled(Rule::BlankLinesBetweenHeaderAndContent) { let mut diagnostic = Diagnostic::new( - NoBlankLinesBetweenHeaderAndContent { + BlankLinesBetweenHeaderAndContent { name: context.section_name.to_string(), }, Range::from(docstring.expr), @@ -613,10 +613,10 @@ fn blanks_and_section_underline( if checker .settings .rules - .enabled(Rule::NoBlankLinesBetweenHeaderAndContent) + .enabled(Rule::BlankLinesBetweenHeaderAndContent) { let mut diagnostic = Diagnostic::new( - NoBlankLinesBetweenHeaderAndContent { + BlankLinesBetweenHeaderAndContent { name: context.section_name.to_string(), }, Range::from(docstring.expr), @@ -735,9 +735,13 @@ fn common_section(checker: &mut Checker, docstring: &Docstring, context: &Sectio checker.diagnostics.push(diagnostic); } } else { - if checker.settings.rules.enabled(Rule::BlankLineAfterSection) { + if checker + .settings + .rules + .enabled(Rule::NoBlankLineAfterSection) + { let mut diagnostic = Diagnostic::new( - BlankLineAfterSection { + NoBlankLineAfterSection { name: context.section_name.to_string(), }, Range::from(docstring.expr), @@ -760,10 +764,14 @@ fn common_section(checker: &mut Checker, docstring: &Docstring, context: &Sectio } } - if checker.settings.rules.enabled(Rule::BlankLineBeforeSection) { + if checker + .settings + .rules + .enabled(Rule::NoBlankLineBeforeSection) + { if !context.previous_line.is_empty() { let mut diagnostic = Diagnostic::new( - BlankLineBeforeSection { + NoBlankLineBeforeSection { name: context.section_name.to_string(), }, Range::from(docstring.expr), diff --git a/crates/ruff/src/rules/pydocstyle/settings.rs b/crates/ruff/src/rules/pydocstyle/settings.rs index 441bc52ffc..a3366b9055 100644 --- a/crates/ruff/src/rules/pydocstyle/settings.rs +++ b/crates/ruff/src/rules/pydocstyle/settings.rs @@ -38,7 +38,7 @@ impl Convention { Rule::BlankLineAfterLastSection, ], Convention::Numpy => &[ - Rule::PublicInit, + Rule::UndocumentedPublicInit, Rule::OneBlankLineBeforeClass, Rule::MultiLineSummaryFirstLine, Rule::MultiLineSummarySecondLine, @@ -60,8 +60,8 @@ impl Convention { Rule::DashedUnderlineAfterSection, Rule::SectionUnderlineAfterName, Rule::SectionUnderlineMatchesSectionLength, - Rule::BlankLineAfterSection, - Rule::BlankLineBeforeSection, + Rule::NoBlankLineAfterSection, + Rule::NoBlankLineBeforeSection, Rule::BlankLineAfterLastSection, Rule::EndsInPunctuation, Rule::SectionNameEndsInColon, diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap index 6465c3fe6f..b9d4dd79b0 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicModule + name: UndocumentedPublicModule body: Missing docstring in public module suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap index a8cd118adf..b4a19961a2 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicClass + name: UndocumentedPublicClass body: Missing docstring in public class suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap index 6df4195b5d..f466079ec0 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicMethod + name: UndocumentedPublicMethod body: Missing docstring in public method suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PublicMethod + name: UndocumentedPublicMethod body: Missing docstring in public method suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PublicMethod + name: UndocumentedPublicMethod body: Missing docstring in public method suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap index c6a4b7dbc0..1c71738400 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicMethod + name: UndocumentedPublicMethod body: Missing docstring in public method suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap index dcbac5146b..3a1c0fea2f 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicFunction + name: UndocumentedPublicFunction body: Missing docstring in public function suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap index 8367b199df..5b959b2fbb 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicPackage + name: UndocumentedPublicPackage body: Missing docstring in public package suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap index 94128ea806..e134d4f8f2 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: MagicMethod + name: UndocumentedMagicMethod body: Missing docstring in magic method suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap index 1d1f8137c2..59cc37f39c 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: PublicInit + name: UndocumentedPublicInit body: "Missing docstring in `__init__`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PublicInit + name: UndocumentedPublicInit body: "Missing docstring in `__init__`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap index 7469e805a1..dbcb6f849a 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: NoUnderIndentation + name: UnderIndentation body: Docstring is under-indented suggestion: Increase indentation fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: NoUnderIndentation + name: UnderIndentation body: Docstring is under-indented suggestion: Increase indentation fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: NoUnderIndentation + name: UnderIndentation body: Docstring is under-indented suggestion: Increase indentation fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: NoUnderIndentation + name: UnderIndentation body: Docstring is under-indented suggestion: Increase indentation fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap index 7fcf000823..847741752f 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: NoOverIndentation + name: OverIndentation body: Docstring is over-indented suggestion: Remove over-indentation fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: NoOverIndentation + name: OverIndentation body: Docstring is over-indented suggestion: Remove over-indentation fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: NoOverIndentation + name: OverIndentation body: Docstring is over-indented suggestion: Remove over-indentation fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap index 1869a6c80c..e198b3ca53 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: NoSurroundingWhitespace + name: SurroundingWhitespace body: No whitespaces allowed surrounding docstring text suggestion: Trim surrounding whitespace fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: NoSurroundingWhitespace + name: SurroundingWhitespace body: No whitespaces allowed surrounding docstring text suggestion: Trim surrounding whitespace fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: NoSurroundingWhitespace + name: SurroundingWhitespace body: No whitespaces allowed surrounding docstring text suggestion: Trim surrounding whitespace fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 36 parent: ~ - kind: - name: NoSurroundingWhitespace + name: SurroundingWhitespace body: No whitespaces allowed surrounding docstring text suggestion: Trim surrounding whitespace fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap index b491fc6cd8..5808fb0885 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: NoBlankLineBeforeClass + name: BlankLineBeforeClass body: No blank lines allowed before class docstring suggestion: Remove blank line(s) before class docstring fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: NoBlankLineBeforeClass + name: BlankLineBeforeClass body: No blank lines allowed before class docstring suggestion: Remove blank line(s) before class docstring fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap index a7f9a705d4..e43d165ab6 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: BlankLineAfterSection + name: NoBlankLineAfterSection body: "Missing blank line after section (\"Returns\")" suggestion: "Add blank line after \"Returns\"" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 11 parent: ~ - kind: - name: BlankLineAfterSection + name: NoBlankLineAfterSection body: "Missing blank line after section (\"Returns\")" suggestion: "Add blank line after \"Returns\"" fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap index 61730a11b2..b9f8cf5a87 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: BlankLineBeforeSection + name: NoBlankLineBeforeSection body: "Missing blank line before section (\"Yields\")" suggestion: "Add blank line before \"Yields\"" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: BlankLineBeforeSection + name: NoBlankLineBeforeSection body: "Missing blank line before section (\"Returns\")" suggestion: "Add blank line before \"Returns\"" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 0 parent: ~ - kind: - name: BlankLineBeforeSection + name: NoBlankLineBeforeSection body: "Missing blank line before section (\"Raises\")" suggestion: "Add blank line before \"Raises\"" fixable: true diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap index 1ef073211b..1d9436d0e1 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pydocstyle/mod.rs expression: diagnostics --- - kind: - name: NoBlankLinesBetweenHeaderAndContent + name: BlankLinesBetweenHeaderAndContent body: "No blank lines allowed between a section header and its content (\"Short summary\")" suggestion: Remove blank line(s) fixable: true diff --git a/crates/ruff/src/rules/pyflakes/mod.rs b/crates/ruff/src/rules/pyflakes/mod.rs index eb0e4e2c1c..b6fab7ddf1 100644 --- a/crates/ruff/src/rules/pyflakes/mod.rs +++ b/crates/ruff/src/rules/pyflakes/mod.rs @@ -35,10 +35,10 @@ mod tests { #[test_case(Rule::UnusedImport, Path::new("F401_9.py"); "F401_9")] #[test_case(Rule::UnusedImport, Path::new("F401_10.py"); "F401_10")] #[test_case(Rule::ImportShadowedByLoopVar, Path::new("F402.py"); "F402")] - #[test_case(Rule::ImportStar, Path::new("F403.py"); "F403")] + #[test_case(Rule::UndefinedLocalWithImportStar, Path::new("F403.py"); "F403")] #[test_case(Rule::LateFutureImport, Path::new("F404.py"); "F404")] - #[test_case(Rule::ImportStarUsage, Path::new("F405.py"); "F405")] - #[test_case(Rule::ImportStarNotPermitted, Path::new("F406.py"); "F406")] + #[test_case(Rule::UndefinedLocalWithImportStarUsage, Path::new("F405.py"); "F405")] + #[test_case(Rule::UndefinedLocalWithNestedImportStarUsage, Path::new("F406.py"); "F406")] #[test_case(Rule::FutureFeatureNotDefined, Path::new("F407.py"); "F407")] #[test_case(Rule::PercentFormatInvalidFormat, Path::new("F50x.py"); "F501")] #[test_case(Rule::PercentFormatExpectedMapping, Path::new("F502.py"); "F502_1")] @@ -61,7 +61,7 @@ mod tests { #[test_case(Rule::FStringMissingPlaceholders, Path::new("F541.py"); "F541")] #[test_case(Rule::MultiValueRepeatedKeyLiteral, Path::new("F601.py"); "F601")] #[test_case(Rule::MultiValueRepeatedKeyVariable, Path::new("F602.py"); "F602")] - #[test_case(Rule::TwoStarredExpressions, Path::new("F622.py"); "F622")] + #[test_case(Rule::MultipleStarredExpressions, Path::new("F622.py"); "F622")] #[test_case(Rule::AssertTuple, Path::new("F631.py"); "F631")] #[test_case(Rule::IsLiteral, Path::new("F632.py"); "F632")] #[test_case(Rule::InvalidPrintSyntax, Path::new("F633.py"); "F633")] @@ -469,7 +469,10 @@ mod tests { // Can't find undefined names with import *. flakes( "from fu import *; bar", - &[Rule::ImportStar, Rule::ImportStarUsage], + &[ + Rule::UndefinedLocalWithImportStar, + Rule::UndefinedLocalWithImportStarUsage, + ], ); } @@ -2485,10 +2488,10 @@ mod tests { csc(1) "#, &[ - Rule::ImportStar, - Rule::ImportStarUsage, - Rule::ImportStarUsage, - Rule::ImportStarUsage, + Rule::UndefinedLocalWithImportStar, + Rule::UndefinedLocalWithImportStarUsage, + Rule::UndefinedLocalWithImportStarUsage, + Rule::UndefinedLocalWithImportStarUsage, ], ); } @@ -2503,7 +2506,7 @@ mod tests { a = 1 __all__ = ['a'] "#, - &[Rule::ImportStar, Rule::UnusedImport], + &[Rule::UndefinedLocalWithImportStar, Rule::UnusedImport], ); } diff --git a/crates/ruff/src/rules/pyflakes/rules/imports.rs b/crates/ruff/src/rules/pyflakes/rules/imports.rs index 5d73571834..08540bd25b 100644 --- a/crates/ruff/src/rules/pyflakes/rules/imports.rs +++ b/crates/ruff/src/rules/pyflakes/rules/imports.rs @@ -66,14 +66,14 @@ impl Violation for ImportShadowedByLoopVar { } #[violation] -pub struct ImportStar { +pub struct UndefinedLocalWithImportStar { pub name: String, } -impl Violation for ImportStar { +impl Violation for UndefinedLocalWithImportStar { #[derive_message_formats] fn message(&self) -> String { - let ImportStar { name } = self; + let UndefinedLocalWithImportStar { name } = self; format!("`from {name} import *` used; unable to detect undefined names") } } @@ -89,15 +89,15 @@ impl Violation for LateFutureImport { } #[violation] -pub struct ImportStarUsage { +pub struct UndefinedLocalWithImportStarUsage { pub name: String, pub sources: Vec, } -impl Violation for ImportStarUsage { +impl Violation for UndefinedLocalWithImportStarUsage { #[derive_message_formats] fn message(&self) -> String { - let ImportStarUsage { name, sources } = self; + let UndefinedLocalWithImportStarUsage { name, sources } = self; let sources = sources .iter() .map(|source| format!("`{source}`")) @@ -107,14 +107,14 @@ impl Violation for ImportStarUsage { } #[violation] -pub struct ImportStarNotPermitted { +pub struct UndefinedLocalWithNestedImportStarUsage { pub name: String, } -impl Violation for ImportStarNotPermitted { +impl Violation for UndefinedLocalWithNestedImportStarUsage { #[derive_message_formats] fn message(&self) -> String { - let ImportStarNotPermitted { name } = self; + let UndefinedLocalWithNestedImportStarUsage { name } = self; format!("`from {name} import *` only allowed at module level") } } diff --git a/crates/ruff/src/rules/pyflakes/rules/mod.rs b/crates/ruff/src/rules/pyflakes/rules/mod.rs index 5f2c90b331..34c07fa11f 100644 --- a/crates/ruff/src/rules/pyflakes/rules/mod.rs +++ b/crates/ruff/src/rules/pyflakes/rules/mod.rs @@ -8,8 +8,9 @@ pub use f_string_missing_placeholders::{ pub use forward_annotation_syntax_error::ForwardAnnotationSyntaxError; pub use if_tuple::{if_tuple, IfTuple}; pub use imports::{ - future_feature_not_defined, FutureFeatureNotDefined, ImportShadowedByLoopVar, ImportStar, - ImportStarNotPermitted, ImportStarUsage, LateFutureImport, UnusedImport, + future_feature_not_defined, FutureFeatureNotDefined, ImportShadowedByLoopVar, LateFutureImport, + UndefinedLocalWithImportStar, UndefinedLocalWithImportStarUsage, + UndefinedLocalWithNestedImportStarUsage, UnusedImport, }; pub use invalid_literal_comparisons::{invalid_literal_comparison, IsLiteral}; pub use invalid_print_syntax::{invalid_print_syntax, InvalidPrintSyntax}; @@ -20,7 +21,7 @@ pub use repeated_keys::{ }; pub use return_outside_function::{return_outside_function, ReturnOutsideFunction}; pub use starred_expressions::{ - starred_expressions, ExpressionsInStarAssignment, TwoStarredExpressions, + starred_expressions, ExpressionsInStarAssignment, MultipleStarredExpressions, }; pub(crate) use strings::{ percent_format_expected_mapping, percent_format_expected_sequence, diff --git a/crates/ruff/src/rules/pyflakes/rules/starred_expressions.rs b/crates/ruff/src/rules/pyflakes/rules/starred_expressions.rs index 35da2160dc..1707bb148e 100644 --- a/crates/ruff/src/rules/pyflakes/rules/starred_expressions.rs +++ b/crates/ruff/src/rules/pyflakes/rules/starred_expressions.rs @@ -15,9 +15,9 @@ impl Violation for ExpressionsInStarAssignment { } #[violation] -pub struct TwoStarredExpressions; +pub struct MultipleStarredExpressions; -impl Violation for TwoStarredExpressions { +impl Violation for MultipleStarredExpressions { #[derive_message_formats] fn message(&self) -> String { format!("Two starred expressions in assignment") @@ -36,7 +36,7 @@ pub fn starred_expressions( for (index, elt) in elts.iter().enumerate() { if matches!(elt.node, ExprKind::Starred { .. }) { if has_starred && check_two_starred_expressions { - return Some(Diagnostic::new(TwoStarredExpressions, location)); + return Some(Diagnostic::new(MultipleStarredExpressions, location)); } has_starred = true; starred_index = Some(index); diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap index 97e57eefff..9c0e4b4714 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyflakes/mod.rs expression: diagnostics --- - kind: - name: ImportStar + name: UndefinedLocalWithImportStar body: "`from F634 import *` used; unable to detect undefined names" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ImportStar + name: UndefinedLocalWithImportStar body: "`from F634 import *` used; unable to detect undefined names" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap index 1d657f1e63..8198af8529 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyflakes/mod.rs expression: diagnostics --- - kind: - name: ImportStarUsage + name: UndefinedLocalWithImportStarUsage body: "`name` may be undefined, or defined from star imports: `mymodule`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ImportStarUsage + name: UndefinedLocalWithImportStarUsage body: "`a` may be undefined, or defined from star imports: `mymodule`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap index 4b08e944bc..c101ddb004 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyflakes/mod.rs expression: diagnostics --- - kind: - name: ImportStarNotPermitted + name: UndefinedLocalWithNestedImportStarUsage body: "`from F634 import *` only allowed at module level" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ImportStarNotPermitted + name: UndefinedLocalWithNestedImportStarUsage body: "`from F634 import *` only allowed at module level" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap index 0766a78568..60d21ceeb5 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyflakes/mod.rs expression: diagnostics --- - kind: - name: TwoStarredExpressions + name: MultipleStarredExpressions body: Two starred expressions in assignment suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pygrep_hooks/mod.rs b/crates/ruff/src/rules/pygrep_hooks/mod.rs index a2317d8dc3..19372b7446 100644 --- a/crates/ruff/src/rules/pygrep_hooks/mod.rs +++ b/crates/ruff/src/rules/pygrep_hooks/mod.rs @@ -13,8 +13,8 @@ mod tests { use crate::settings; use crate::test::test_path; - #[test_case(Rule::NoEval, Path::new("PGH001_0.py"); "PGH001_0")] - #[test_case(Rule::NoEval, Path::new("PGH001_1.py"); "PGH001_1")] + #[test_case(Rule::Eval, Path::new("PGH001_0.py"); "PGH001_0")] + #[test_case(Rule::Eval, Path::new("PGH001_1.py"); "PGH001_1")] #[test_case(Rule::DeprecatedLogWarn, Path::new("PGH002_0.py"); "PGH002_0")] #[test_case(Rule::DeprecatedLogWarn, Path::new("PGH002_1.py"); "PGH002_1")] #[test_case(Rule::BlanketTypeIgnore, Path::new("PGH003_0.py"); "PGH003_0")] diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/mod.rs b/crates/ruff/src/rules/pygrep_hooks/rules/mod.rs index d1cfb8d298..4454dad548 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/mod.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/mod.rs @@ -1,7 +1,7 @@ pub use blanket_noqa::{blanket_noqa, BlanketNOQA}; pub use blanket_type_ignore::{blanket_type_ignore, BlanketTypeIgnore}; pub use deprecated_log_warn::{deprecated_log_warn, DeprecatedLogWarn}; -pub use no_eval::{no_eval, NoEval}; +pub use no_eval::{no_eval, Eval}; mod blanket_noqa; mod blanket_type_ignore; diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs b/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs index a3c030e964..0c68501b85 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs @@ -7,9 +7,9 @@ use ruff_python_ast::types::Range; use crate::checkers::ast::Checker; #[violation] -pub struct NoEval; +pub struct Eval; -impl Violation for NoEval { +impl Violation for Eval { #[derive_message_formats] fn message(&self) -> String { format!("No builtin `eval()` allowed") @@ -28,5 +28,5 @@ pub fn no_eval(checker: &mut Checker, func: &Expr) { } checker .diagnostics - .push(Diagnostic::new(NoEval, Range::from(func))); + .push(Diagnostic::new(Eval, Range::from(func))); } diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap index 47cb5e844b..2261bf5cef 100644 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap +++ b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pygrep_hooks/mod.rs expression: diagnostics --- - kind: - name: NoEval + name: Eval body: "No builtin `eval()` allowed" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: NoEval + name: Eval body: "No builtin `eval()` allowed" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pylint/mod.rs b/crates/ruff/src/rules/pylint/mod.rs index 0cf76dd4e2..17b8ec3d55 100644 --- a/crates/ruff/src/rules/pylint/mod.rs +++ b/crates/ruff/src/rules/pylint/mod.rs @@ -25,15 +25,15 @@ mod tests { #[test_case(Rule::CollapsibleElseIf, Path::new("collapsible_else_if.py"); "PLR5501")] #[test_case(Rule::CompareToEmptyString, Path::new("compare_to_empty_string.py"); "PLC1901")] #[test_case(Rule::ComparisonOfConstant, Path::new("comparison_of_constant.py"); "PLR0133")] - #[test_case(Rule::ConsiderMergingIsinstance, Path::new("consider_merging_isinstance.py"); "PLR1701")] - #[test_case(Rule::ConsiderUsingFromImport, Path::new("import_aliasing.py"); "PLR0402")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_0.py"); "PLR1722_0")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_1.py"); "PLR1722_1")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_2.py"); "PLR1722_2")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_3.py"); "PLR1722_3")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_4.py"); "PLR1722_4")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_5.py"); "PLR1722_5")] - #[test_case(Rule::ConsiderUsingSysExit, Path::new("consider_using_sys_exit_6.py"); "PLR1722_6")] + #[test_case(Rule::RepeatedIsinstanceCalls, Path::new("repeated_isinstance_calls.py"); "PLR1701")] + #[test_case(Rule::ManualFromImport, Path::new("import_aliasing.py"); "PLR0402")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_0.py"); "PLR1722_0")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_1.py"); "PLR1722_1")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_2.py"); "PLR1722_2")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_3.py"); "PLR1722_3")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_4.py"); "PLR1722_4")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_5.py"); "PLR1722_5")] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_6.py"); "PLR1722_6")] #[test_case(Rule::ContinueInFinally, Path::new("continue_in_finally.py"); "PLE0116")] #[test_case(Rule::GlobalStatement, Path::new("global_statement.py"); "PLW0603")] #[test_case(Rule::GlobalVariableNotAssigned, Path::new("global_variable_not_assigned.py"); "PLW0602")] @@ -58,7 +58,7 @@ mod tests { #[test_case(Rule::TooManyReturnStatements, Path::new("too_many_return_statements.py"); "PLR0911")] #[test_case(Rule::TooManyStatements, Path::new("too_many_statements.py"); "PLR0915")] #[test_case(Rule::UnnecessaryDirectLambdaCall, Path::new("unnecessary_direct_lambda_call.py"); "PLC3002")] - #[test_case(Rule::UsedPriorGlobalDeclaration, Path::new("used_prior_global_declaration.py"); "PLE0118")] + #[test_case(Rule::UsePriorToGlobalDeclaration, Path::new("use_prior_to_global_declaration.py"); "PLE0118")] #[test_case(Rule::UselessElseOnLoop, Path::new("useless_else_on_loop.py"); "PLW0120")] #[test_case(Rule::UselessImportAlias, Path::new("import_aliasing.py"); "PLC0414")] #[test_case(Rule::UselessReturn, Path::new("useless_return.py"); "PLR1711")] diff --git a/crates/ruff/src/rules/pylint/rules/use_from_import.rs b/crates/ruff/src/rules/pylint/rules/manual_import_from.rs similarity index 85% rename from crates/ruff/src/rules/pylint/rules/use_from_import.rs rename to crates/ruff/src/rules/pylint/rules/manual_import_from.rs index e05975ff6d..05845ad44d 100644 --- a/crates/ruff/src/rules/pylint/rules/use_from_import.rs +++ b/crates/ruff/src/rules/pylint/rules/manual_import_from.rs @@ -9,31 +9,31 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct ConsiderUsingFromImport { +pub struct ManualFromImport { pub module: String, pub name: String, pub fixable: bool, } -impl Violation for ConsiderUsingFromImport { +impl Violation for ManualFromImport { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] fn message(&self) -> String { - let ConsiderUsingFromImport { module, name, .. } = self; + let ManualFromImport { module, name, .. } = self; format!("Use `from {module} import {name}` in lieu of alias") } fn autofix_title_formatter(&self) -> Option String> { self.fixable - .then_some(|ConsiderUsingFromImport { module, name, .. }| { + .then_some(|ManualFromImport { module, name, .. }| { format!("Replace with `from {module} import {name}`") }) } } /// PLR0402 -pub fn use_from_import(checker: &mut Checker, stmt: &Stmt, alias: &Alias, names: &[Alias]) { +pub fn manual_from_import(checker: &mut Checker, stmt: &Stmt, alias: &Alias, names: &[Alias]) { let Some(asname) = &alias.node.asname else { return; }; @@ -46,7 +46,7 @@ pub fn use_from_import(checker: &mut Checker, stmt: &Stmt, alias: &Alias, names: let fixable = names.len() == 1; let mut diagnostic = Diagnostic::new( - ConsiderUsingFromImport { + ManualFromImport { module: module.to_string(), name: name.to_string(), fixable, diff --git a/crates/ruff/src/rules/pylint/rules/mod.rs b/crates/ruff/src/rules/pylint/rules/mod.rs index 1bd908b5e8..4fa3baacf6 100644 --- a/crates/ruff/src/rules/pylint/rules/mod.rs +++ b/crates/ruff/src/rules/pylint/rules/mod.rs @@ -5,7 +5,6 @@ pub use bidirectional_unicode::{bidirectional_unicode, BidirectionalUnicode}; pub use collapsible_else_if::{collapsible_else_if, CollapsibleElseIf}; pub use compare_to_empty_string::{compare_to_empty_string, CompareToEmptyString}; pub use comparison_of_constant::{comparison_of_constant, ComparisonOfConstant}; -pub use consider_using_sys_exit::{consider_using_sys_exit, ConsiderUsingSysExit}; pub use continue_in_finally::{continue_in_finally, ContinueInFinally}; pub use global_statement::{global_statement, GlobalStatement}; pub use global_variable_not_assigned::GlobalVariableNotAssigned; @@ -19,11 +18,13 @@ pub use invalid_string_characters::{ }; pub use logging::{logging_call, LoggingTooFewArgs, LoggingTooManyArgs}; pub use magic_value_comparison::{magic_value_comparison, MagicValueComparison}; -pub use merge_isinstance::{merge_isinstance, ConsiderMergingIsinstance}; +pub use manual_import_from::{manual_from_import, ManualFromImport}; pub use nonlocal_without_binding::NonlocalWithoutBinding; pub use property_with_parameters::{property_with_parameters, PropertyWithParameters}; pub use redefined_loop_name::{redefined_loop_name, RedefinedLoopName}; +pub use repeated_isinstance_calls::{repeated_isinstance_calls, RepeatedIsinstanceCalls}; pub use return_in_init::{return_in_init, ReturnInInit}; +pub use sys_exit_alias::{sys_exit_alias, SysExitAlias}; pub use too_many_arguments::{too_many_arguments, TooManyArguments}; pub use too_many_branches::{too_many_branches, TooManyBranches}; pub use too_many_return_statements::{too_many_return_statements, TooManyReturnStatements}; @@ -31,9 +32,8 @@ pub use too_many_statements::{too_many_statements, TooManyStatements}; pub use unnecessary_direct_lambda_call::{ unnecessary_direct_lambda_call, UnnecessaryDirectLambdaCall, }; -pub use use_from_import::{use_from_import, ConsiderUsingFromImport}; -pub use used_prior_global_declaration::{ - used_prior_global_declaration, UsedPriorGlobalDeclaration, +pub use use_prior_to_global_declaration::{ + use_prior_to_global_declaration, UsePriorToGlobalDeclaration, }; pub use useless_else_on_loop::{useless_else_on_loop, UselessElseOnLoop}; pub use useless_import_alias::{useless_import_alias, UselessImportAlias}; @@ -47,7 +47,6 @@ mod bidirectional_unicode; mod collapsible_else_if; mod compare_to_empty_string; mod comparison_of_constant; -mod consider_using_sys_exit; mod continue_in_finally; mod global_statement; mod global_variable_not_assigned; @@ -58,18 +57,19 @@ mod invalid_envvar_value; mod invalid_string_characters; mod logging; mod magic_value_comparison; -mod merge_isinstance; +mod manual_import_from; mod nonlocal_without_binding; mod property_with_parameters; mod redefined_loop_name; +mod repeated_isinstance_calls; mod return_in_init; +mod sys_exit_alias; mod too_many_arguments; mod too_many_branches; mod too_many_return_statements; mod too_many_statements; mod unnecessary_direct_lambda_call; -mod use_from_import; -mod used_prior_global_declaration; +mod use_prior_to_global_declaration; mod useless_else_on_loop; mod useless_import_alias; mod useless_return; diff --git a/crates/ruff/src/rules/pylint/rules/merge_isinstance.rs b/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs similarity index 88% rename from crates/ruff/src/rules/pylint/rules/merge_isinstance.rs rename to crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs index a2a01403b6..abd7388318 100644 --- a/crates/ruff/src/rules/pylint/rules/merge_isinstance.rs +++ b/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs @@ -11,22 +11,22 @@ use ruff_python_ast::types::Range; use crate::checkers::ast::Checker; #[violation] -pub struct ConsiderMergingIsinstance { +pub struct RepeatedIsinstanceCalls { pub obj: String, pub types: Vec, } -impl Violation for ConsiderMergingIsinstance { +impl Violation for RepeatedIsinstanceCalls { #[derive_message_formats] fn message(&self) -> String { - let ConsiderMergingIsinstance { obj, types } = self; + let RepeatedIsinstanceCalls { obj, types } = self; let types = types.join(", "); format!("Merge these isinstance calls: `isinstance({obj}, ({types}))`") } } /// PLR1701 -pub fn merge_isinstance(checker: &mut Checker, expr: &Expr, op: &Boolop, values: &[Expr]) { +pub fn repeated_isinstance_calls(checker: &mut Checker, expr: &Expr, op: &Boolop, values: &[Expr]) { if !matches!(op, Boolop::Or) || !checker.ctx.is_builtin("isinstance") { return; } @@ -59,7 +59,7 @@ pub fn merge_isinstance(checker: &mut Checker, expr: &Expr, op: &Boolop, values: for (obj, (num_calls, types)) in obj_to_types { if num_calls > 1 && types.len() > 1 { checker.diagnostics.push(Diagnostic::new( - ConsiderMergingIsinstance { + RepeatedIsinstanceCalls { obj: unparse_expr(obj.as_expr(), checker.stylist), types: types .iter() diff --git a/crates/ruff/src/rules/pylint/rules/consider_using_sys_exit.rs b/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs similarity index 93% rename from crates/ruff/src/rules/pylint/rules/consider_using_sys_exit.rs rename to crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs index ae30328450..a5203bac7c 100644 --- a/crates/ruff/src/rules/pylint/rules/consider_using_sys_exit.rs +++ b/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs @@ -9,21 +9,21 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct ConsiderUsingSysExit { +pub struct SysExitAlias { pub name: String, } -impl Violation for ConsiderUsingSysExit { +impl Violation for SysExitAlias { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] fn message(&self) -> String { - let ConsiderUsingSysExit { name } = self; + let SysExitAlias { name } = self; format!("Use `sys.exit()` instead of `{name}`") } fn autofix_title_formatter(&self) -> Option String> { - Some(|ConsiderUsingSysExit { name }| format!("Replace `{name}` with `sys.exit()`")) + Some(|SysExitAlias { name }| format!("Replace `{name}` with `sys.exit()`")) } } /// Return `true` if the `module` was imported using a star import (e.g., `from @@ -96,7 +96,7 @@ fn get_member_import_name_alias(checker: &Checker, module: &str, member: &str) - } /// PLR1722 -pub fn consider_using_sys_exit(checker: &mut Checker, func: &Expr) { +pub fn sys_exit_alias(checker: &mut Checker, func: &Expr) { let ExprKind::Name { id, .. } = &func.node else { return; }; @@ -111,7 +111,7 @@ pub fn consider_using_sys_exit(checker: &mut Checker, func: &Expr) { continue; } let mut diagnostic = Diagnostic::new( - ConsiderUsingSysExit { + SysExitAlias { name: name.to_string(), }, Range::from(func), diff --git a/crates/ruff/src/rules/pylint/rules/used_prior_global_declaration.rs b/crates/ruff/src/rules/pylint/rules/use_prior_to_global_declaration.rs similarity index 77% rename from crates/ruff/src/rules/pylint/rules/used_prior_global_declaration.rs rename to crates/ruff/src/rules/pylint/rules/use_prior_to_global_declaration.rs index e3bb759db8..b31e1e637d 100644 --- a/crates/ruff/src/rules/pylint/rules/used_prior_global_declaration.rs +++ b/crates/ruff/src/rules/pylint/rules/use_prior_to_global_declaration.rs @@ -8,20 +8,20 @@ use ruff_python_ast::types::Range; use crate::checkers::ast::Checker; #[violation] -pub struct UsedPriorGlobalDeclaration { +pub struct UsePriorToGlobalDeclaration { pub name: String, pub line: usize, } -impl Violation for UsedPriorGlobalDeclaration { +impl Violation for UsePriorToGlobalDeclaration { #[derive_message_formats] fn message(&self) -> String { - let UsedPriorGlobalDeclaration { name, line } = self; + let UsePriorToGlobalDeclaration { name, line } = self; format!("Name `{name}` is used prior to global declaration on line {line}") } } /// PLE0118 -pub fn used_prior_global_declaration(checker: &mut Checker, name: &str, expr: &Expr) { +pub fn use_prior_to_global_declaration(checker: &mut Checker, name: &str, expr: &Expr) { let globals = match &checker.ctx.scope().kind { ScopeKind::Class(class_def) => &class_def.globals, ScopeKind::Function(function_def) => &function_def.globals, @@ -30,7 +30,7 @@ pub fn used_prior_global_declaration(checker: &mut Checker, name: &str, expr: &E if let Some(stmt) = globals.get(name) { if expr.location < stmt.location { checker.diagnostics.push(Diagnostic::new( - UsedPriorGlobalDeclaration { + UsePriorToGlobalDeclaration { name: name.to_string(), line: stmt.location.row(), }, diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_used_prior_global_declaration.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_use_prior_to_global_declaration.py.snap similarity index 85% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_used_prior_global_declaration.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_use_prior_to_global_declaration.py.snap index b1a014b6b8..870e447382 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_used_prior_global_declaration.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_use_prior_to_global_declaration.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 7" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 17" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 25" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 35" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 43" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 53" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 61" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 71" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 79" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 89" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 97" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 107" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UsedPriorGlobalDeclaration + name: UsePriorToGlobalDeclaration body: "Name `x` is used prior to global declaration on line 114" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap index c16c6d990c..913c22ba60 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingFromImport + name: ManualFromImport body: "Use `from os import path` in lieu of alias" suggestion: "Replace with `from os import path`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: ConsiderUsingFromImport + name: ManualFromImport body: "Use `from foo.bar import foobar` in lieu of alias" suggestion: "Replace with `from foo.bar import foobar`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 31 parent: ~ - kind: - name: ConsiderUsingFromImport + name: ManualFromImport body: "Use `from foo.bar import foobar` in lieu of alias" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_consider_merging_isinstance.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap similarity index 86% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_consider_merging_isinstance.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap index 6e1ab26b10..23b0e7f2a1 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_consider_merging_isinstance.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderMergingIsinstance + name: RepeatedIsinstanceCalls body: "Merge these isinstance calls: `isinstance(var[3], (float, int))`" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderMergingIsinstance + name: RepeatedIsinstanceCalls body: "Merge these isinstance calls: `isinstance(var[4], (float, int))`" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderMergingIsinstance + name: RepeatedIsinstanceCalls body: "Merge these isinstance calls: `isinstance(var[5], (float, int))`" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderMergingIsinstance + name: RepeatedIsinstanceCalls body: "Merge these isinstance calls: `isinstance(var[10], (list, str))`" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderMergingIsinstance + name: RepeatedIsinstanceCalls body: "Merge these isinstance calls: `isinstance(var[11], (float, int))`" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderMergingIsinstance + name: RepeatedIsinstanceCalls body: "Merge these isinstance calls: `isinstance(var[12], (float, int, list))`" suggestion: ~ fixable: false diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_0.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap similarity index 88% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_0.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap index 8aa20e1524..22d0407e3c 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_0.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_1.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap similarity index 91% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_1.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap index f7eca30fd1..6a63792286 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_1.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_2.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap similarity index 91% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_2.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap index 6e9a6c7291..70d0d1bfb7 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_2.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_3.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap similarity index 92% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_3.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap index bc69bd958d..ce71f751f2 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_3.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_4.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap similarity index 91% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_4.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap index 2799ef4576..8d0d1c486b 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_4.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_5.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap similarity index 92% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_5.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap index bc69bd958d..ce71f751f2 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_5.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 4 parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_6.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap similarity index 89% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_6.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap index 04a718aa44..01c3275d9b 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_consider_using_sys_exit_6.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pylint/mod.rs expression: diagnostics --- - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `exit`" suggestion: "Replace `exit` with `sys.exit()`" fixable: true @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: ConsiderUsingSysExit + name: SysExitAlias body: "Use `sys.exit()` instead of `quit`" suggestion: "Replace `quit` with `sys.exit()`" fixable: true diff --git a/crates/ruff/src/rules/pyupgrade/mod.rs b/crates/ruff/src/rules/pyupgrade/mod.rs index 20477fdb83..a491a6804e 100644 --- a/crates/ruff/src/rules/pyupgrade/mod.rs +++ b/crates/ruff/src/rules/pyupgrade/mod.rs @@ -40,17 +40,17 @@ mod tests { #[test_case(Rule::TypingTextStrAlias, Path::new("UP019.py"); "UP019")] #[test_case(Rule::ReplaceUniversalNewlines, Path::new("UP021.py"); "UP021")] #[test_case(Rule::ReplaceStdoutStderr, Path::new("UP022.py"); "UP022")] - #[test_case(Rule::RewriteCElementTree, Path::new("UP023.py"); "UP023")] + #[test_case(Rule::DeprecatedCElementTree, Path::new("UP023.py"); "UP023")] #[test_case(Rule::OSErrorAlias, Path::new("UP024_0.py"); "UP024_0")] #[test_case(Rule::OSErrorAlias, Path::new("UP024_1.py"); "UP024_1")] #[test_case(Rule::OSErrorAlias, Path::new("UP024_2.py"); "UP024_2")] #[test_case(Rule::OSErrorAlias, Path::new("UP024_3.py"); "UP024_3")] #[test_case(Rule::OSErrorAlias, Path::new("UP024_4.py"); "UP024_4")] - #[test_case(Rule::RewriteUnicodeLiteral, Path::new("UP025.py"); "UP025")] - #[test_case(Rule::RewriteMockImport, Path::new("UP026.py"); "UP026")] - #[test_case(Rule::RewriteListComprehension, Path::new("UP027.py"); "UP027")] - #[test_case(Rule::RewriteYieldFrom, Path::new("UP028_0.py"); "UP028_0")] - #[test_case(Rule::RewriteYieldFrom, Path::new("UP028_1.py"); "UP028_1")] + #[test_case(Rule::UnicodeKindPrefix, Path::new("UP025.py"); "UP025")] + #[test_case(Rule::DeprecatedMockImport, Path::new("UP026.py"); "UP026")] + #[test_case(Rule::UnpackedListComprehension, Path::new("UP027.py"); "UP027")] + #[test_case(Rule::YieldInForLoop, Path::new("UP028_0.py"); "UP028_0")] + #[test_case(Rule::YieldInForLoop, Path::new("UP028_1.py"); "UP028_1")] #[test_case(Rule::UnnecessaryBuiltinImport, Path::new("UP029.py"); "UP029")] #[test_case(Rule::FormatLiterals, Path::new("UP030_0.py"); "UP030_0")] #[test_case(Rule::FormatLiterals, Path::new("UP030_1.py"); "UP030_1")] @@ -58,7 +58,7 @@ mod tests { #[test_case(Rule::PrintfStringFormatting, Path::new("UP031_0.py"); "UP031_0")] #[test_case(Rule::PrintfStringFormatting, Path::new("UP031_1.py"); "UP031_1")] #[test_case(Rule::FString, Path::new("UP032.py"); "UP032")] - #[test_case(Rule::FunctoolsCache, Path::new("UP033.py"); "UP033")] + #[test_case(Rule::LRUCacheWithMaxsizeNone, Path::new("UP033.py"); "UP033")] #[test_case(Rule::ExtraneousParentheses, Path::new("UP034.py"); "UP034")] #[test_case(Rule::DeprecatedImport, Path::new("UP035.py"); "UP035")] #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_0.py"); "UP036_0")] diff --git a/crates/ruff/src/rules/pyupgrade/rules/rewrite_c_element_tree.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs similarity index 89% rename from crates/ruff/src/rules/pyupgrade/rules/rewrite_c_element_tree.rs rename to crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs index 9855130135..df4538ce7e 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/rewrite_c_element_tree.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs @@ -8,9 +8,9 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct RewriteCElementTree; +pub struct DeprecatedCElementTree; -impl AlwaysAutofixableViolation for RewriteCElementTree { +impl AlwaysAutofixableViolation for DeprecatedCElementTree { #[derive_message_formats] fn message(&self) -> String { format!("`cElementTree` is deprecated, use `ElementTree`") @@ -22,7 +22,7 @@ impl AlwaysAutofixableViolation for RewriteCElementTree { } fn add_check_for_node(checker: &mut Checker, node: &Located) { - let mut diagnostic = Diagnostic::new(RewriteCElementTree, Range::from(node)); + let mut diagnostic = Diagnostic::new(DeprecatedCElementTree, Range::from(node)); if checker.patch(diagnostic.kind.rule()) { let contents = checker.locator.slice(node); diagnostic.amend(Fix::replacement( @@ -35,7 +35,7 @@ fn add_check_for_node(checker: &mut Checker, node: &Located) { } /// UP023 -pub fn replace_c_element_tree(checker: &mut Checker, stmt: &Stmt) { +pub fn deprecated_c_element_tree(checker: &mut Checker, stmt: &Stmt) { match &stmt.node { StmtKind::Import { names } => { // Ex) `import xml.etree.cElementTree as ET` diff --git a/crates/ruff/src/rules/pyupgrade/rules/rewrite_mock_import.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs similarity index 95% rename from crates/ruff/src/rules/pyupgrade/rules/rewrite_mock_import.rs rename to crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs index 924dcc4ae0..1e7ea0dc76 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/rewrite_mock_import.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs @@ -24,18 +24,18 @@ pub enum MockReference { } #[violation] -pub struct RewriteMockImport { +pub struct DeprecatedMockImport { pub reference_type: MockReference, } -impl AlwaysAutofixableViolation for RewriteMockImport { +impl AlwaysAutofixableViolation for DeprecatedMockImport { #[derive_message_formats] fn message(&self) -> String { format!("`mock` is deprecated, use `unittest.mock`") } fn autofix_title(&self) -> String { - let RewriteMockImport { reference_type } = self; + let DeprecatedMockImport { reference_type } = self; match reference_type { MockReference::Import => "Import from `unittest.mock` instead".to_string(), MockReference::Attribute => "Replace `mock.mock` with `mock`".to_string(), @@ -246,11 +246,11 @@ fn format_import_from( } /// UP026 -pub fn rewrite_mock_attribute(checker: &mut Checker, expr: &Expr) { +pub fn deprecated_mock_attribute(checker: &mut Checker, expr: &Expr) { if let ExprKind::Attribute { value, .. } = &expr.node { if collect_call_path(value).as_slice() == ["mock", "mock"] { let mut diagnostic = Diagnostic::new( - RewriteMockImport { + DeprecatedMockImport { reference_type: MockReference::Attribute, }, Range::from(value), @@ -268,7 +268,7 @@ pub fn rewrite_mock_attribute(checker: &mut Checker, expr: &Expr) { } /// UP026 -pub fn rewrite_mock_import(checker: &mut Checker, stmt: &Stmt) { +pub fn deprecated_mock_import(checker: &mut Checker, stmt: &Stmt) { match &stmt.node { StmtKind::Import { names } => { // Find all `mock` imports. @@ -277,7 +277,7 @@ pub fn rewrite_mock_import(checker: &mut Checker, stmt: &Stmt) { .any(|name| name.node.name == "mock" || name.node.name == "mock.mock") { // Generate the fix, if needed, which is shared between all `mock` imports. - let content = if checker.patch(Rule::RewriteMockImport) { + let content = if checker.patch(Rule::DeprecatedMockImport) { if let Some(indent) = indentation(checker.locator, stmt) { match format_import(stmt, indent, checker.locator, checker.stylist) { Ok(content) => Some(content), @@ -297,7 +297,7 @@ pub fn rewrite_mock_import(checker: &mut Checker, stmt: &Stmt) { for name in names { if name.node.name == "mock" || name.node.name == "mock.mock" { let mut diagnostic = Diagnostic::new( - RewriteMockImport { + DeprecatedMockImport { reference_type: MockReference::Import, }, Range::from(name), @@ -325,7 +325,7 @@ pub fn rewrite_mock_import(checker: &mut Checker, stmt: &Stmt) { if module == "mock" { let mut diagnostic = Diagnostic::new( - RewriteMockImport { + DeprecatedMockImport { reference_type: MockReference::Import, }, Range::from(stmt), diff --git a/crates/ruff/src/rules/pyupgrade/rules/functools_cache.rs b/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs similarity index 91% rename from crates/ruff/src/rules/pyupgrade/rules/functools_cache.rs rename to crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs index cbaae97107..7aa52bd76f 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/functools_cache.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs @@ -9,9 +9,9 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct FunctoolsCache; +pub struct LRUCacheWithMaxsizeNone; -impl AlwaysAutofixableViolation for FunctoolsCache { +impl AlwaysAutofixableViolation for LRUCacheWithMaxsizeNone { #[derive_message_formats] fn message(&self) -> String { format!("Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`") @@ -23,7 +23,7 @@ impl AlwaysAutofixableViolation for FunctoolsCache { } /// UP033 -pub fn functools_cache(checker: &mut Checker, decorator_list: &[Expr]) { +pub fn lru_cache_with_maxsize_none(checker: &mut Checker, decorator_list: &[Expr]) { for expr in decorator_list.iter() { let ExprKind::Call { func, @@ -54,7 +54,7 @@ pub fn functools_cache(checker: &mut Checker, decorator_list: &[Expr]) { ) { let mut diagnostic = Diagnostic::new( - FunctoolsCache, + LRUCacheWithMaxsizeNone, Range::new(func.end_location.unwrap(), expr.end_location.unwrap()), ); if checker.patch(diagnostic.kind.rule()) { diff --git a/crates/ruff/src/rules/pyupgrade/rules/mod.rs b/crates/ruff/src/rules/pyupgrade/rules/mod.rs index 26654fd4a1..41b9d03d85 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/mod.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/mod.rs @@ -5,12 +5,18 @@ pub(crate) use convert_typed_dict_functional_to_class::{ convert_typed_dict_functional_to_class, ConvertTypedDictFunctionalToClass, }; pub(crate) use datetime_utc_alias::{datetime_utc_alias, DatetimeTimezoneUTC}; +pub(crate) use deprecated_c_element_tree::{deprecated_c_element_tree, DeprecatedCElementTree}; pub(crate) use deprecated_import::{deprecated_import, DeprecatedImport}; +pub(crate) use deprecated_mock_import::{ + deprecated_mock_attribute, deprecated_mock_import, DeprecatedMockImport, +}; pub(crate) use deprecated_unittest_alias::{deprecated_unittest_alias, DeprecatedUnittestAlias}; pub(crate) use extraneous_parentheses::{extraneous_parentheses, ExtraneousParentheses}; pub(crate) use f_strings::{f_strings, FString}; pub(crate) use format_literals::{format_literals, FormatLiterals}; -pub(crate) use functools_cache::{functools_cache, FunctoolsCache}; +pub(crate) use lru_cache_with_maxsize_none::{ + lru_cache_with_maxsize_none, LRUCacheWithMaxsizeNone, +}; pub(crate) use lru_cache_without_parameters::{ lru_cache_without_parameters, LRUCacheWithoutParameters, }; @@ -25,35 +31,35 @@ pub(crate) use quoted_annotation::{quoted_annotation, QuotedAnnotation}; pub(crate) use redundant_open_modes::{redundant_open_modes, RedundantOpenModes}; pub(crate) use replace_stdout_stderr::{replace_stdout_stderr, ReplaceStdoutStderr}; pub(crate) use replace_universal_newlines::{replace_universal_newlines, ReplaceUniversalNewlines}; -pub(crate) use rewrite_c_element_tree::{replace_c_element_tree, RewriteCElementTree}; -pub(crate) use rewrite_mock_import::{ - rewrite_mock_attribute, rewrite_mock_import, RewriteMockImport, -}; -pub(crate) use rewrite_unicode_literal::{rewrite_unicode_literal, RewriteUnicodeLiteral}; -pub(crate) use rewrite_yield_from::{rewrite_yield_from, RewriteYieldFrom}; pub(crate) use super_call_with_parameters::{super_call_with_parameters, SuperCallWithParameters}; pub(crate) use type_of_primitive::{type_of_primitive, TypeOfPrimitive}; pub(crate) use typing_text_str_alias::{typing_text_str_alias, TypingTextStrAlias}; +pub(crate) use unicode_kind_prefix::{unicode_kind_prefix, UnicodeKindPrefix}; pub(crate) use unnecessary_builtin_import::{unnecessary_builtin_import, UnnecessaryBuiltinImport}; pub(crate) use unnecessary_coding_comment::{unnecessary_coding_comment, UTF8EncodingDeclaration}; pub(crate) use unnecessary_encode_utf8::{unnecessary_encode_utf8, UnnecessaryEncodeUTF8}; pub(crate) use unnecessary_future_import::{unnecessary_future_import, UnnecessaryFutureImport}; -pub(crate) use unpack_list_comprehension::{unpack_list_comprehension, RewriteListComprehension}; +pub(crate) use unpacked_list_comprehension::{ + unpacked_list_comprehension, UnpackedListComprehension, +}; pub(crate) use use_pep585_annotation::{use_pep585_annotation, DeprecatedCollectionType}; pub(crate) use use_pep604_annotation::{use_pep604_annotation, TypingUnion}; pub(crate) use use_pep604_isinstance::{use_pep604_isinstance, IsinstanceWithTuple}; pub(crate) use useless_metaclass_type::{useless_metaclass_type, UselessMetaclassType}; pub(crate) use useless_object_inheritance::{useless_object_inheritance, UselessObjectInheritance}; +pub(crate) use yield_in_for_loop::{yield_in_for_loop, YieldInForLoop}; mod convert_named_tuple_functional_to_class; mod convert_typed_dict_functional_to_class; mod datetime_utc_alias; +mod deprecated_c_element_tree; mod deprecated_import; +mod deprecated_mock_import; mod deprecated_unittest_alias; mod extraneous_parentheses; mod f_strings; mod format_literals; -mod functools_cache; +mod lru_cache_with_maxsize_none; mod lru_cache_without_parameters; mod native_literals; mod open_alias; @@ -64,20 +70,18 @@ mod quoted_annotation; mod redundant_open_modes; mod replace_stdout_stderr; mod replace_universal_newlines; -mod rewrite_c_element_tree; -mod rewrite_mock_import; -mod rewrite_unicode_literal; -mod rewrite_yield_from; mod super_call_with_parameters; mod type_of_primitive; mod typing_text_str_alias; +mod unicode_kind_prefix; mod unnecessary_builtin_import; mod unnecessary_coding_comment; mod unnecessary_encode_utf8; mod unnecessary_future_import; -mod unpack_list_comprehension; +mod unpacked_list_comprehension; mod use_pep585_annotation; mod use_pep604_annotation; mod use_pep604_isinstance; mod useless_metaclass_type; mod useless_object_inheritance; +mod yield_in_for_loop; diff --git a/crates/ruff/src/rules/pyupgrade/rules/rewrite_unicode_literal.rs b/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs similarity index 77% rename from crates/ruff/src/rules/pyupgrade/rules/rewrite_unicode_literal.rs rename to crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs index e3a9af2ec7..3a6dc20257 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/rewrite_unicode_literal.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs @@ -8,9 +8,9 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct RewriteUnicodeLiteral; +pub struct UnicodeKindPrefix; -impl AlwaysAutofixableViolation for RewriteUnicodeLiteral { +impl AlwaysAutofixableViolation for UnicodeKindPrefix { #[derive_message_formats] fn message(&self) -> String { format!("Remove unicode literals from strings") @@ -22,10 +22,10 @@ impl AlwaysAutofixableViolation for RewriteUnicodeLiteral { } /// UP025 -pub fn rewrite_unicode_literal(checker: &mut Checker, expr: &Expr, kind: Option<&str>) { +pub fn unicode_kind_prefix(checker: &mut Checker, expr: &Expr, kind: Option<&str>) { if let Some(const_kind) = kind { if const_kind.to_lowercase() == "u" { - let mut diagnostic = Diagnostic::new(RewriteUnicodeLiteral, Range::from(expr)); + let mut diagnostic = Diagnostic::new(UnicodeKindPrefix, Range::from(expr)); if checker.patch(diagnostic.kind.rule()) { diagnostic.amend(Fix::deletion( expr.location, diff --git a/crates/ruff/src/rules/pyupgrade/rules/unpack_list_comprehension.rs b/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs similarity index 93% rename from crates/ruff/src/rules/pyupgrade/rules/unpack_list_comprehension.rs rename to crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs index 840e41c477..1055ce2844 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unpack_list_comprehension.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs @@ -8,9 +8,9 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct RewriteListComprehension; +pub struct UnpackedListComprehension; -impl AlwaysAutofixableViolation for RewriteListComprehension { +impl AlwaysAutofixableViolation for UnpackedListComprehension { #[derive_message_formats] fn message(&self) -> String { format!("Replace unpacked list comprehension with a generator expression") @@ -84,7 +84,7 @@ fn contains_await(expr: &Expr) -> bool { } /// UP027 -pub fn unpack_list_comprehension(checker: &mut Checker, targets: &[Expr], value: &Expr) { +pub fn unpacked_list_comprehension(checker: &mut Checker, targets: &[Expr], value: &Expr) { let Some(target) = targets.get(0) else { return; }; @@ -94,7 +94,7 @@ pub fn unpack_list_comprehension(checker: &mut Checker, targets: &[Expr], value: return; } - let mut diagnostic = Diagnostic::new(RewriteListComprehension, Range::from(value)); + let mut diagnostic = Diagnostic::new(UnpackedListComprehension, Range::from(value)); if checker.patch(diagnostic.kind.rule()) { let existing = checker.locator.slice(value); diff --git a/crates/ruff/src/rules/pyupgrade/rules/rewrite_yield_from.rs b/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs similarity index 96% rename from crates/ruff/src/rules/pyupgrade/rules/rewrite_yield_from.rs rename to crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs index 032dadd31f..ed64cf4569 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/rewrite_yield_from.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs @@ -11,9 +11,9 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct RewriteYieldFrom; +pub struct YieldInForLoop; -impl AlwaysAutofixableViolation for RewriteYieldFrom { +impl AlwaysAutofixableViolation for YieldInForLoop { #[derive_message_formats] fn message(&self) -> String { format!("Replace `yield` over `for` loop with `yield from`") @@ -147,7 +147,7 @@ impl<'a> Visitor<'a> for ReferenceVisitor<'a> { } /// UP028 -pub fn rewrite_yield_from(checker: &mut Checker, stmt: &Stmt) { +pub fn yield_in_for_loop(checker: &mut Checker, stmt: &Stmt) { // Intentionally omit async functions. if let StmtKind::FunctionDef { body, .. } = &stmt.node { let yields = { @@ -172,7 +172,7 @@ pub fn rewrite_yield_from(checker: &mut Checker, stmt: &Stmt) { continue; } - let mut diagnostic = Diagnostic::new(RewriteYieldFrom, Range::from(item.stmt)); + let mut diagnostic = Diagnostic::new(YieldInForLoop, Range::from(item.stmt)); if checker.patch(diagnostic.kind.rule()) { let contents = checker.locator.slice(item.iter); let contents = format!("yield from {contents}"); diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap index fcf107949c..d757231a5a 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 59 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 35 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 44 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 49 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 39 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 40 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 47 parent: ~ - kind: - name: RewriteCElementTree + name: DeprecatedCElementTree body: "`cElementTree` is deprecated, use `ElementTree`" suggestion: "Replace with `ElementTree`" fixable: true diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap index fceb98b0a4..6cdba34315 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 7 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 27 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 39 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -203,7 +203,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true @@ -223,7 +223,7 @@ expression: diagnostics column: 5 parent: ~ - kind: - name: RewriteUnicodeLiteral + name: UnicodeKindPrefix body: Remove unicode literals from strings suggestion: Remove unicode prefix fixable: true diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap index 49a288bdd1..35b374b6ae 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 16 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 28 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 16 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -203,7 +203,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -223,7 +223,7 @@ expression: diagnostics column: 1 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -243,7 +243,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -263,7 +263,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -283,7 +283,7 @@ expression: diagnostics column: 9 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -303,7 +303,7 @@ expression: diagnostics column: 17 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -323,7 +323,7 @@ expression: diagnostics column: 17 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -343,7 +343,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -363,7 +363,7 @@ expression: diagnostics column: 28 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -383,7 +383,7 @@ expression: diagnostics column: 41 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -403,7 +403,7 @@ expression: diagnostics column: 41 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -423,7 +423,7 @@ expression: diagnostics column: 41 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -443,7 +443,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -463,7 +463,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -483,7 +483,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Import from `unittest.mock` instead" fixable: true @@ -503,7 +503,7 @@ expression: diagnostics column: 51 parent: ~ - kind: - name: RewriteMockImport + name: DeprecatedMockImport body: "`mock` is deprecated, use `unittest.mock`" suggestion: "Replace `mock.mock` with `mock`" fixable: true diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap index 5a57eb3217..416c921040 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - name: RewriteListComprehension + name: UnpackedListComprehension body: Replace unpacked list comprehension with a generator expression suggestion: Replace with generator expression fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 38 parent: ~ - kind: - name: RewriteListComprehension + name: UnpackedListComprehension body: Replace unpacked list comprehension with a generator expression suggestion: Replace with generator expression fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 37 parent: ~ - kind: - name: RewriteListComprehension + name: UnpackedListComprehension body: Replace unpacked list comprehension with a generator expression suggestion: Replace with generator expression fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 47 parent: ~ - kind: - name: RewriteListComprehension + name: UnpackedListComprehension body: Replace unpacked list comprehension with a generator expression suggestion: Replace with generator expression fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 51 parent: ~ - kind: - name: RewriteListComprehension + name: UnpackedListComprehension body: Replace unpacked list comprehension with a generator expression suggestion: Replace with generator expression fixable: true diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap index 812715bca0..4799cb213a 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 18 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -203,7 +203,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true @@ -223,7 +223,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: RewriteYieldFrom + name: YieldInForLoop body: "Replace `yield` over `for` loop with `yield from`" suggestion: "Replace with `yield from`" fixable: true diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033.py.snap index 16ffe9abf3..28a1e8a243 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - name: FunctoolsCache + name: LRUCacheWithMaxsizeNone body: "Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`" suggestion: "Rewrite with `@functools.cache" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: FunctoolsCache + name: LRUCacheWithMaxsizeNone body: "Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`" suggestion: "Rewrite with `@functools.cache" fixable: true @@ -36,7 +36,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: FunctoolsCache + name: LRUCacheWithMaxsizeNone body: "Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`" suggestion: "Rewrite with `@functools.cache" fixable: true @@ -56,7 +56,7 @@ expression: diagnostics column: 34 parent: ~ - kind: - name: FunctoolsCache + name: LRUCacheWithMaxsizeNone body: "Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`" suggestion: "Rewrite with `@functools.cache" fixable: true diff --git a/crates/ruff/src/rules/ruff/mod.rs b/crates/ruff/src/rules/ruff/mod.rs index bfee0c2be6..9fc616052c 100644 --- a/crates/ruff/src/rules/ruff/mod.rs +++ b/crates/ruff/src/rules/ruff/mod.rs @@ -17,7 +17,7 @@ mod tests { use crate::settings::types::PerFileIgnore; use crate::test::test_path; - #[test_case(Rule::UnpackInsteadOfConcatenatingToCollectionLiteral, Path::new("RUF005.py"); "RUF005")] + #[test_case(Rule::CollectionLiteralConcatenation, Path::new("RUF005.py"); "RUF005")] #[test_case(Rule::AsyncioDanglingTask, Path::new("RUF006.py"); "RUF006")] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); @@ -55,7 +55,7 @@ mod tests { Rule::LineTooLong, Rule::UnusedImport, Rule::UnusedVariable, - Rule::IndentationContainsTabs, + Rule::TabIndentation, ]), )?; assert_yaml_snapshot!(diagnostics); diff --git a/crates/ruff/src/rules/ruff/rules/unpack_instead_of_concatenating_to_collection_literal.rs b/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs similarity index 87% rename from crates/ruff/src/rules/ruff/rules/unpack_instead_of_concatenating_to_collection_literal.rs rename to crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs index 6893a663af..29cc599175 100644 --- a/crates/ruff/src/rules/ruff/rules/unpack_instead_of_concatenating_to_collection_literal.rs +++ b/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs @@ -9,26 +9,25 @@ use crate::checkers::ast::Checker; use crate::registry::AsRule; #[violation] -pub struct UnpackInsteadOfConcatenatingToCollectionLiteral { +pub struct CollectionLiteralConcatenation { pub expr: String, pub fixable: bool, } -impl Violation for UnpackInsteadOfConcatenatingToCollectionLiteral { +impl Violation for CollectionLiteralConcatenation { const AUTOFIX: Option = Some(AutofixKind::new(Availability::Sometimes)); #[derive_message_formats] fn message(&self) -> String { - let UnpackInsteadOfConcatenatingToCollectionLiteral { expr, .. } = self; + let CollectionLiteralConcatenation { expr, .. } = self; format!("Consider `{expr}` instead of concatenation") } fn autofix_title_formatter(&self) -> Option String> { - self.fixable.then_some( - |UnpackInsteadOfConcatenatingToCollectionLiteral { expr, .. }| { + self.fixable + .then_some(|CollectionLiteralConcatenation { expr, .. }| { format!("Replace with `{expr}`") - }, - ) + }) } } @@ -59,7 +58,7 @@ enum Kind { /// RUF005 /// This suggestion could be unsafe if the non-literal expression in the /// expression has overridden the `__add__` (or `__radd__`) magic methods. -pub fn unpack_instead_of_concatenating_to_collection_literal(checker: &mut Checker, expr: &Expr) { +pub fn collection_literal_concatenation(checker: &mut Checker, expr: &Expr) { let ExprKind::BinOp { op, left, right } = &expr.node else { return; }; @@ -105,7 +104,7 @@ pub fn unpack_instead_of_concatenating_to_collection_literal(checker: &mut Check let fixable = !has_comments(expr, checker.locator); let mut diagnostic = Diagnostic::new( - UnpackInsteadOfConcatenatingToCollectionLiteral { + CollectionLiteralConcatenation { expr: contents.clone(), fixable, }, diff --git a/crates/ruff/src/rules/ruff/rules/mod.rs b/crates/ruff/src/rules/ruff/rules/mod.rs index 0460ae4a77..04841e63dd 100644 --- a/crates/ruff/src/rules/ruff/rules/mod.rs +++ b/crates/ruff/src/rules/ruff/rules/mod.rs @@ -1,7 +1,7 @@ mod ambiguous_unicode_character; mod asyncio_dangling_task; +mod collection_literal_concatenation; mod pairwise_over_zipped; -mod unpack_instead_of_concatenating_to_collection_literal; mod unused_noqa; pub use ambiguous_unicode_character::{ @@ -9,11 +9,10 @@ pub use ambiguous_unicode_character::{ AmbiguousUnicodeCharacterDocstring, AmbiguousUnicodeCharacterString, }; pub use asyncio_dangling_task::{asyncio_dangling_task, AsyncioDanglingTask}; -pub use pairwise_over_zipped::{pairwise_over_zipped, PairwiseOverZipped}; -pub use unpack_instead_of_concatenating_to_collection_literal::{ - unpack_instead_of_concatenating_to_collection_literal, - UnpackInsteadOfConcatenatingToCollectionLiteral, +pub use collection_literal_concatenation::{ + collection_literal_concatenation, CollectionLiteralConcatenation, }; +pub use pairwise_over_zipped::{pairwise_over_zipped, PairwiseOverZipped}; pub use unused_noqa::{UnusedCodes, UnusedNOQA}; #[derive(Clone, Copy)] diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap index ebc36dfecb..d8f5d9a72e 100644 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap +++ b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/ruff/mod.rs expression: diagnostics --- - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `[1, 2, 3, *foo]` instead of concatenation" suggestion: "Replace with `[1, 2, 3, *foo]`" fixable: true @@ -23,7 +23,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(7, 8, 9, *zoob)` instead of concatenation" suggestion: "Replace with `(7, 8, 9, *zoob)`" fixable: true @@ -43,7 +43,7 @@ expression: diagnostics column: 23 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(*quux, 10, 11, 12)` instead of concatenation" suggestion: "Replace with `(*quux, 10, 11, 12)`" fixable: true @@ -63,7 +63,7 @@ expression: diagnostics column: 26 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `[*spom, 13, 14, 15]` instead of concatenation" suggestion: "Replace with `[*spom, 13, 14, 15]`" fixable: true @@ -83,7 +83,7 @@ expression: diagnostics column: 26 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(\"we all say\", *yay())` instead of concatenation" suggestion: "Replace with `(\"we all say\", *yay())`" fixable: true @@ -103,7 +103,7 @@ expression: diagnostics column: 36 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(\"we all think\", *Fun().yay())` instead of concatenation" suggestion: "Replace with `(\"we all think\", *Fun().yay())`" fixable: true @@ -123,7 +123,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(\"we all feel\", *Fun.words)` instead of concatenation" suggestion: "Replace with `(\"we all feel\", *Fun.words)`" fixable: true @@ -143,7 +143,7 @@ expression: diagnostics column: 44 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `[\"a\", \"b\", \"c\", *eggs]` instead of concatenation" suggestion: "Replace with `[\"a\", \"b\", \"c\", *eggs]`" fixable: true @@ -163,7 +163,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(\"yes\", \"no\", \"pants\", *zoob)` instead of concatenation" suggestion: "Replace with `(\"yes\", \"no\", \"pants\", *zoob)`" fixable: true @@ -183,7 +183,7 @@ expression: diagnostics column: 67 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `(*zoob,)` instead of concatenation" suggestion: "Replace with `(*zoob,)`" fixable: true @@ -203,7 +203,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `[*first, 4, 5, 6]` instead of concatenation" suggestion: ~ fixable: false @@ -216,7 +216,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `[*foo]` instead of concatenation" suggestion: "Replace with `[*foo]`" fixable: true @@ -236,7 +236,7 @@ expression: diagnostics column: 8 parent: ~ - kind: - name: UnpackInsteadOfConcatenatingToCollectionLiteral + name: CollectionLiteralConcatenation body: "Consider `[*foo]` instead of concatenation" suggestion: "Replace with `[*foo]`" fixable: true diff --git a/crates/ruff/src/rules/tryceratops/mod.rs b/crates/ruff/src/rules/tryceratops/mod.rs index a7e710439e..c6a13008fb 100644 --- a/crates/ruff/src/rules/tryceratops/mod.rs +++ b/crates/ruff/src/rules/tryceratops/mod.rs @@ -17,7 +17,7 @@ mod tests { #[test_case(Rule::RaiseVanillaClass, Path::new("TRY002.py"); "TRY002")] #[test_case(Rule::RaiseVanillaArgs, Path::new("TRY003.py"); "TRY003")] - #[test_case(Rule::PreferTypeError, Path::new("TRY004.py"); "TRY004")] + #[test_case(Rule::TypeCheckWithoutTypeError, Path::new("TRY004.py"); "TRY004")] #[test_case(Rule::ReraiseNoCause, Path::new("TRY200.py"); "TRY200")] #[test_case(Rule::VerboseRaise, Path::new("TRY201.py"); "TRY201")] #[test_case(Rule::TryConsiderElse, Path::new("TRY300.py"); "TRY300")] diff --git a/crates/ruff/src/rules/tryceratops/rules/mod.rs b/crates/ruff/src/rules/tryceratops/rules/mod.rs index 1438e46c9e..c1ee2203f5 100644 --- a/crates/ruff/src/rules/tryceratops/rules/mod.rs +++ b/crates/ruff/src/rules/tryceratops/rules/mod.rs @@ -1,19 +1,19 @@ pub use error_instead_of_exception::{error_instead_of_exception, ErrorInsteadOfException}; -pub use prefer_type_error::{prefer_type_error, PreferTypeError}; pub use raise_vanilla_args::{raise_vanilla_args, RaiseVanillaArgs}; pub use raise_vanilla_class::{raise_vanilla_class, RaiseVanillaClass}; pub use raise_within_try::{raise_within_try, RaiseWithinTry}; pub use reraise_no_cause::{reraise_no_cause, ReraiseNoCause}; pub use try_consider_else::{try_consider_else, TryConsiderElse}; +pub use type_check_without_type_error::{type_check_without_type_error, TypeCheckWithoutTypeError}; pub use verbose_log_message::{verbose_log_message, VerboseLogMessage}; pub use verbose_raise::{verbose_raise, VerboseRaise}; mod error_instead_of_exception; -mod prefer_type_error; mod raise_vanilla_args; mod raise_vanilla_class; mod raise_within_try; mod reraise_no_cause; mod try_consider_else; +mod type_check_without_type_error; mod verbose_log_message; mod verbose_raise; diff --git a/crates/ruff/src/rules/tryceratops/rules/prefer_type_error.rs b/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs similarity index 95% rename from crates/ruff/src/rules/tryceratops/rules/prefer_type_error.rs rename to crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs index 8d93c61fc1..e4891262a6 100644 --- a/crates/ruff/src/rules/tryceratops/rules/prefer_type_error.rs +++ b/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs @@ -9,9 +9,9 @@ use ruff_python_ast::visitor::Visitor; use crate::checkers::ast::Checker; #[violation] -pub struct PreferTypeError; +pub struct TypeCheckWithoutTypeError; -impl Violation for PreferTypeError { +impl Violation for TypeCheckWithoutTypeError { #[derive_message_formats] fn message(&self) -> String { format!("Prefer `TypeError` exception for invalid type") @@ -132,9 +132,10 @@ fn check_raise_type(checker: &mut Checker, exc: &Expr) -> bool { fn check_raise(checker: &mut Checker, exc: &Expr, item: &Stmt) { if check_raise_type(checker, exc) { - checker - .diagnostics - .push(Diagnostic::new(PreferTypeError, Range::from(item))); + checker.diagnostics.push(Diagnostic::new( + TypeCheckWithoutTypeError, + Range::from(item), + )); } } @@ -171,7 +172,7 @@ fn check_orelse(checker: &mut Checker, body: &[Stmt]) { } /// TRY004 -pub fn prefer_type_error( +pub fn type_check_without_type_error( checker: &mut Checker, body: &[Stmt], test: &Expr, diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__prefer-type-error_TRY004.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap similarity index 85% rename from crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__prefer-type-error_TRY004.py.snap rename to crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap index b7518c44fc..6d0dea1ef0 100644 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__prefer-type-error_TRY004.py.snap +++ b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/tryceratops/mod.rs expression: diagnostics --- - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -16,7 +16,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -29,7 +29,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -42,7 +42,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -55,7 +55,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -68,7 +68,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -81,7 +81,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -94,7 +94,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -107,7 +107,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -120,7 +120,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -133,7 +133,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -146,7 +146,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -159,7 +159,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -172,7 +172,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -185,7 +185,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -198,7 +198,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -211,7 +211,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -224,7 +224,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -237,7 +237,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -250,7 +250,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -263,7 +263,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -276,7 +276,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -289,7 +289,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -302,7 +302,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -315,7 +315,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -328,7 +328,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -341,7 +341,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -354,7 +354,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -367,7 +367,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -380,7 +380,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -393,7 +393,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -406,7 +406,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -419,7 +419,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false @@ -432,7 +432,7 @@ expression: diagnostics fix: ~ parent: ~ - kind: - name: PreferTypeError + name: TypeCheckWithoutTypeError body: "Prefer `TypeError` exception for invalid type" suggestion: ~ fixable: false diff --git a/crates/ruff/src/settings/mod.rs b/crates/ruff/src/settings/mod.rs index a27c6b58fe..4a45e13ecc 100644 --- a/crates/ruff/src/settings/mod.rs +++ b/crates/ruff/src/settings/mod.rs @@ -453,11 +453,11 @@ mod tests { let expected = FxHashSet::from_iter([ Rule::TrailingWhitespace, - Rule::NoNewLineAtEndOfFile, - Rule::BlankLineContainsWhitespace, + Rule::MissingNewlineAtEndOfFile, + Rule::BlankLineWithWhitespace, Rule::DocLineTooLong, Rule::InvalidEscapeSequence, - Rule::IndentationContainsTabs, + Rule::TabIndentation, ]); assert_eq!(actual, expected); @@ -475,10 +475,10 @@ mod tests { }]); let expected = FxHashSet::from_iter([ Rule::TrailingWhitespace, - Rule::BlankLineContainsWhitespace, + Rule::BlankLineWithWhitespace, Rule::DocLineTooLong, Rule::InvalidEscapeSequence, - Rule::IndentationContainsTabs, + Rule::TabIndentation, ]); assert_eq!(actual, expected); @@ -487,7 +487,7 @@ mod tests { ignore: vec![Pycodestyle::W.into()], ..RuleSelection::default() }]); - let expected = FxHashSet::from_iter([Rule::NoNewLineAtEndOfFile]); + let expected = FxHashSet::from_iter([Rule::MissingNewlineAtEndOfFile]); assert_eq!(actual, expected); let actual = resolve_rules([RuleSelection { @@ -511,11 +511,11 @@ mod tests { ]); let expected = FxHashSet::from_iter([ Rule::TrailingWhitespace, - Rule::NoNewLineAtEndOfFile, - Rule::BlankLineContainsWhitespace, + Rule::MissingNewlineAtEndOfFile, + Rule::BlankLineWithWhitespace, Rule::DocLineTooLong, Rule::InvalidEscapeSequence, - Rule::IndentationContainsTabs, + Rule::TabIndentation, ]); assert_eq!(actual, expected); @@ -531,7 +531,7 @@ mod tests { ..RuleSelection::default() }, ]); - let expected = FxHashSet::from_iter([Rule::NoNewLineAtEndOfFile]); + let expected = FxHashSet::from_iter([Rule::MissingNewlineAtEndOfFile]); assert_eq!(actual, expected); } @@ -550,10 +550,10 @@ mod tests { ]); let expected = FxHashSet::from_iter([ Rule::TrailingWhitespace, - Rule::BlankLineContainsWhitespace, + Rule::BlankLineWithWhitespace, Rule::DocLineTooLong, Rule::InvalidEscapeSequence, - Rule::IndentationContainsTabs, + Rule::TabIndentation, ]); assert_eq!(actual, expected); @@ -571,9 +571,9 @@ mod tests { ]); let expected = FxHashSet::from_iter([ Rule::TrailingWhitespace, - Rule::BlankLineContainsWhitespace, + Rule::BlankLineWithWhitespace, Rule::InvalidEscapeSequence, - Rule::IndentationContainsTabs, + Rule::TabIndentation, ]); assert_eq!(actual, expected); }