diff --git a/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs b/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs index def136a437..4221fd81e3 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs @@ -93,6 +93,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) { pyflakes::rules::undefined_local(checker, scope_id, scope); } + // PLW0602 if checker.is_rule_enabled(Rule::GlobalVariableNotAssigned) { for (name, binding_id) in scope.bindings() { let binding = checker.semantic.binding(binding_id); @@ -123,6 +124,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) { } } + // PLR1704 if checker.is_rule_enabled(Rule::RedefinedArgumentFromLocal) { for (name, binding_id) in scope.bindings() { for shadow in checker.semantic.shadowed_bindings(scope_id, binding_id) { @@ -156,6 +158,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) { } } + // F402 if checker.is_rule_enabled(Rule::ImportShadowedByLoopVar) { for (name, binding_id) in scope.bindings() { for shadow in checker.semantic.shadowed_bindings(scope_id, binding_id) { @@ -197,6 +200,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) { } } + // F811 if checker.is_rule_enabled(Rule::RedefinedWhileUnused) { // Index the redefined bindings by statement. let mut redefinitions = FxHashMap::default(); diff --git a/crates/ruff_linter/src/checkers/ast/analyze/expression.rs b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs index c30e76dff7..3437fbba22 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/expression.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs @@ -539,6 +539,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) { let location = expr.range(); match pyflakes::format::FormatSummary::try_from(string_value.to_str()) { Err(e) => { + // F521 if checker.is_rule_enabled(Rule::StringDotFormatInvalidFormat) { checker.report_diagnostic( pyflakes::rules::StringDotFormatInvalidFormat { @@ -1315,6 +1316,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) { typ: CFormatErrorType::UnsupportedFormatChar(c), .. }) => { + // F509 if checker .is_rule_enabled(Rule::PercentFormatUnsupportedFormatCharacter) { @@ -1327,6 +1329,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) { } } Err(e) => { + // F501 if checker.is_rule_enabled(Rule::PercentFormatInvalidFormat) { checker.report_diagnostic( pyflakes::rules::PercentFormatInvalidFormat { diff --git a/crates/ruff_linter/src/checkers/ast/analyze/statement.rs b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs index 704a8d65df..d1d949a529 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/statement.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs @@ -828,6 +828,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { pyflakes::rules::future_feature_not_defined(checker, alias); } } else if &alias.name == "*" { + // F406 if checker.is_rule_enabled(Rule::UndefinedLocalWithNestedImportStarUsage) { if !matches!(checker.semantic.current_scope().kind, ScopeKind::Module) { checker.report_diagnostic( @@ -838,6 +839,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { ); } } + // F403 if checker.is_rule_enabled(Rule::UndefinedLocalWithImportStar) { checker.report_diagnostic( pyflakes::rules::UndefinedLocalWithImportStar { diff --git a/crates/ruff_linter/src/checkers/ast/analyze/unresolved_references.rs b/crates/ruff_linter/src/checkers/ast/analyze/unresolved_references.rs index 021cfd7d1f..9456813eb2 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/unresolved_references.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/unresolved_references.rs @@ -13,6 +13,7 @@ pub(crate) fn unresolved_references(checker: &Checker) { for reference in checker.semantic.unresolved_references() { if reference.is_wildcard_import() { + // F406 if checker.is_rule_enabled(Rule::UndefinedLocalWithImportStarUsage) { checker.report_diagnostic( pyflakes::rules::UndefinedLocalWithImportStarUsage { @@ -22,6 +23,7 @@ pub(crate) fn unresolved_references(checker: &Checker) { ); } } else { + // F821 if checker.is_rule_enabled(Rule::UndefinedName) { if checker.semantic.in_no_type_check() { continue; diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs index 9b0a306d34..84cbf824e2 100644 --- a/crates/ruff_linter/src/checkers/ast/mod.rs +++ b/crates/ruff_linter/src/checkers/ast/mod.rs @@ -625,6 +625,7 @@ impl SemanticSyntaxContext for Checker<'_> { fn report_semantic_error(&self, error: SemanticSyntaxError) { match error.kind { SemanticSyntaxErrorKind::LateFutureImport => { + // F404 if self.is_rule_enabled(Rule::LateFutureImport) { self.report_diagnostic(LateFutureImport, error.range); } @@ -646,6 +647,7 @@ impl SemanticSyntaxContext for Checker<'_> { } } SemanticSyntaxErrorKind::ReturnOutsideFunction => { + // F706 if self.is_rule_enabled(Rule::ReturnOutsideFunction) { self.report_diagnostic(ReturnOutsideFunction, error.range); } @@ -2808,6 +2810,7 @@ impl<'a> Checker<'a> { Err(parse_error) => { self.semantic.restore(snapshot); + // F722 if self.is_rule_enabled(Rule::ForwardAnnotationSyntaxError) { self.report_type_diagnostic( pyflakes::rules::ForwardAnnotationSyntaxError { @@ -2955,6 +2958,7 @@ impl<'a> Checker<'a> { self.semantic.flags -= SemanticModelFlags::DUNDER_ALL_DEFINITION; } else { if self.semantic.global_scope().uses_star_imports() { + // F405 if self.is_rule_enabled(Rule::UndefinedLocalWithImportStarUsage) { self.report_diagnostic( pyflakes::rules::UndefinedLocalWithImportStarUsage { @@ -2965,6 +2969,7 @@ impl<'a> Checker<'a> { .set_parent(definition.start()); } } else { + // F822 if self.is_rule_enabled(Rule::UndefinedExport) { if is_undefined_export_in_dunder_init_enabled(self.settings()) || !self.path.ends_with("__init__.py") diff --git a/crates/ruff_linter/src/checkers/noqa.rs b/crates/ruff_linter/src/checkers/noqa.rs index ac553b21e5..62a9f81b4e 100644 --- a/crates/ruff_linter/src/checkers/noqa.rs +++ b/crates/ruff_linter/src/checkers/noqa.rs @@ -22,6 +22,7 @@ use crate::{Edit, Fix, Locator}; use super::ast::LintContext; +/// RUF100 pub(crate) fn check_noqa( context: &mut LintContext, path: &Path, diff --git a/crates/ruff_linter/src/pyproject_toml.rs b/crates/ruff_linter/src/pyproject_toml.rs index fcc268d5cb..96d1af0937 100644 --- a/crates/ruff_linter/src/pyproject_toml.rs +++ b/crates/ruff_linter/src/pyproject_toml.rs @@ -11,6 +11,7 @@ use crate::registry::Rule; use crate::rules::ruff::rules::InvalidPyprojectToml; use crate::settings::LinterSettings; +/// RUF200 pub fn lint_pyproject_toml( source_file: &SourceFile, settings: &LinterSettings, diff --git a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs index 5b0f24d56f..f419a3deeb 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs @@ -738,6 +738,7 @@ pub(crate) fn definition( .suppress_none_returning && is_none_returning(body) ) { + // ANN206 if is_method && visibility::is_classmethod(decorator_list, checker.semantic()) { if checker.is_rule_enabled(Rule::MissingReturnTypeClassMethod) { let return_type = if is_stub_function(function, checker) { @@ -765,6 +766,7 @@ pub(crate) fn definition( diagnostics.push(diagnostic); } } else if is_method && visibility::is_staticmethod(decorator_list, checker.semantic()) { + // ANN205 if checker.is_rule_enabled(Rule::MissingReturnTypeStaticMethod) { let return_type = if is_stub_function(function, checker) { None @@ -791,6 +793,7 @@ pub(crate) fn definition( diagnostics.push(diagnostic); } } else if is_method && visibility::is_init(name) { + // ANN204 // Allow omission of return annotation in `__init__` functions, as long as at // least one argument is typed. if checker.is_rule_enabled(Rule::MissingReturnTypeSpecialMethod) { diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs index e7350bff8a..b3a97c1d9a 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs @@ -51,6 +51,7 @@ impl Violation for BooleanPositionalValueInCall { } } +/// FBT003 pub(crate) fn boolean_positional_value_in_call(checker: &Checker, call: &ast::ExprCall) { if allow_boolean_trap(call, checker) { return; diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/static_key_dict_comprehension.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/static_key_dict_comprehension.rs index fbcae4568b..ace25f1f55 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/static_key_dict_comprehension.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/static_key_dict_comprehension.rs @@ -46,7 +46,7 @@ impl Violation for StaticKeyDictComprehension { } } -/// RUF011 +/// B035, RUF011 pub(crate) fn static_key_dict_comprehension(checker: &Checker, dict_comp: &ast::ExprDictComp) { // Collect the bound names in the comprehension's generators. let names = { diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs index f1363faf1a..97b76d57fc 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs @@ -58,6 +58,7 @@ impl Violation for CallDateFromtimestamp { } } +/// DTZ012 pub(crate) fn call_date_fromtimestamp(checker: &Checker, func: &Expr, location: TextRange) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs index 34e2bc937d..9557e13613 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs @@ -57,6 +57,7 @@ impl Violation for CallDateToday { } } +/// DTZ011 pub(crate) fn call_date_today(checker: &Checker, func: &Expr, location: TextRange) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs index a0fac4511e..7e443efe74 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs @@ -69,6 +69,7 @@ impl Violation for CallDatetimeFromtimestamp { } } +/// DTZ006 pub(crate) fn call_datetime_fromtimestamp(checker: &Checker, call: &ast::ExprCall) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs index 23760d52db..ceea7e2d84 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs @@ -67,6 +67,7 @@ impl Violation for CallDatetimeNowWithoutTzinfo { } } +/// DTZ005 pub(crate) fn call_datetime_now_without_tzinfo(checker: &Checker, call: &ast::ExprCall) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs index 1273bf0188..f748b8d832 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs @@ -56,6 +56,7 @@ impl Violation for CallDatetimeToday { } } +/// DTZ002 pub(crate) fn call_datetime_today(checker: &Checker, func: &Expr, location: TextRange) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs index 9f918a5e2b..4f6210e026 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs @@ -60,6 +60,7 @@ impl Violation for CallDatetimeUtcfromtimestamp { } } +/// DTZ004 pub(crate) fn call_datetime_utcfromtimestamp(checker: &Checker, func: &Expr, location: TextRange) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs index 0a4d6326dc..d4c53cf324 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs @@ -63,6 +63,7 @@ impl Violation for CallDatetimeWithoutTzinfo { } } +/// DTZ001 pub(crate) fn call_datetime_without_tzinfo(checker: &Checker, call: &ast::ExprCall) { if !checker.semantic().seen_module(Modules::DATETIME) { return; diff --git a/crates/ruff_linter/src/rules/flake8_debugger/rules/debugger.rs b/crates/ruff_linter/src/rules/flake8_debugger/rules/debugger.rs index 401bd2bd61..a068ff4387 100644 --- a/crates/ruff_linter/src/rules/flake8_debugger/rules/debugger.rs +++ b/crates/ruff_linter/src/rules/flake8_debugger/rules/debugger.rs @@ -46,6 +46,7 @@ impl Violation for Debugger { } } +/// T100 /// Checks for the presence of a debugger call. pub(crate) fn debugger_call(checker: &Checker, expr: &Expr, func: &Expr) { if let Some(using_type) = @@ -64,6 +65,7 @@ pub(crate) fn debugger_call(checker: &Checker, expr: &Expr, func: &Expr) { } } +/// T100 /// Checks for the presence of a debugger import. pub(crate) fn debugger_import(checker: &Checker, stmt: &Stmt, module: Option<&str>, name: &str) { if let Some(module) = module { diff --git a/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs index 0cd766ec6e..d1768b4254 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs +++ b/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs @@ -59,6 +59,7 @@ impl Violation for ExcInfoOutsideExceptHandler { } } +/// LOG014 pub(crate) fn exc_info_outside_except_handler(checker: &Checker, call: &ExprCall) { let semantic = checker.semantic(); diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs b/crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs index 8df841b4b0..832096afde 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs +++ b/crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs @@ -171,7 +171,7 @@ pub(crate) fn logging_call(checker: &Checker, call: &ast::ExprCall) { _ => return, }; - // G001 - G004 + // G001, G002, G003, G004 let msg_pos = usize::from(matches!(logging_call_type, LoggingCallType::LogCall)); if let Some(format_arg) = call.arguments.find_argument_value("msg", msg_pos) { check_msg(checker, format_arg); diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs index c9073a051e..cc95dd837a 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs @@ -55,6 +55,7 @@ impl Violation for PytestFailWithoutMessage { } } +/// PT016 pub(crate) fn fail_call(checker: &Checker, call: &ast::ExprCall) { if is_pytest_fail(&call.func, checker.semantic()) { // Allow either `pytest.fail(reason="...")` (introduced in pytest 7.0) or diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs index 96dcfc2aa7..76ffcb71d1 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs @@ -225,6 +225,7 @@ fn check_useless_usefixtures(checker: &Checker, decorator: &Decorator, marker: & diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion(decorator.range()))); } +/// PT023, PT026 pub(crate) fn marks(checker: &Checker, decorators: &[Decorator]) { let enforce_parentheses = checker.is_rule_enabled(Rule::PytestIncorrectMarkParenthesesStyle); let enforce_useless_usefixtures = diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs index 870ca5a2d7..feacfbe937 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs @@ -170,6 +170,7 @@ const fn is_non_trivial_with_body(body: &[Stmt]) -> bool { } } +/// PT010 pub(crate) fn raises_call(checker: &Checker, call: &ast::ExprCall) { if is_pytest_raises(&call.func, checker.semantic()) { if checker.is_rule_enabled(Rule::PytestRaisesWithoutException) { @@ -205,6 +206,7 @@ pub(crate) fn raises_call(checker: &Checker, call: &ast::ExprCall) { } } +/// PT012 pub(crate) fn complex_raises(checker: &Checker, stmt: &Stmt, items: &[WithItem], body: &[Stmt]) { let raises_called = items.iter().any(|item| match &item.context_expr { Expr::Call(ast::ExprCall { func, .. }) => is_pytest_raises(func, checker.semantic()), diff --git a/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs b/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs index 8fe6a908dc..3648c48239 100644 --- a/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs +++ b/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs @@ -154,6 +154,7 @@ fn get_complexity_number(stmts: &[Stmt]) -> usize { complexity } +/// C901 pub(crate) fn function_is_too_complex( checker: &Checker, stmt: &Stmt, diff --git a/crates/ruff_linter/src/rules/pandas_vet/rules/call.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/call.rs index 0ed5cdfc28..8b7619cf3e 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/rules/call.rs +++ b/crates/ruff_linter/src/rules/pandas_vet/rules/call.rs @@ -181,15 +181,19 @@ pub(crate) fn call(checker: &Checker, func: &Expr) { let range = func.range(); match attr.as_str() { + // PD003 "isnull" if checker.is_rule_enabled(Rule::PandasUseOfDotIsNull) => { checker.report_diagnostic(PandasUseOfDotIsNull, range); } + // PD004 "notnull" if checker.is_rule_enabled(Rule::PandasUseOfDotNotNull) => { checker.report_diagnostic(PandasUseOfDotNotNull, range); } + // PD010 "pivot" | "unstack" if checker.is_rule_enabled(Rule::PandasUseOfDotPivotOrUnstack) => { checker.report_diagnostic(PandasUseOfDotPivotOrUnstack, range); } + // PD013 "stack" if checker.is_rule_enabled(Rule::PandasUseOfDotStack) => { checker.report_diagnostic(PandasUseOfDotStack, range); } diff --git a/crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs index bf4f9ea31a..30fc920952 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs +++ b/crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs @@ -163,12 +163,15 @@ pub(crate) fn subscript(checker: &Checker, value: &Expr, expr: &Expr) { let range = expr.range(); match attr.as_str() { + // PD007 "ix" if checker.is_rule_enabled(Rule::PandasUseOfDotIx) => { checker.report_diagnostic(PandasUseOfDotIx, range) } + // PD008 "at" if checker.is_rule_enabled(Rule::PandasUseOfDotAt) => { checker.report_diagnostic(PandasUseOfDotAt, range) } + // PD009 "iat" if checker.is_rule_enabled(Rule::PandasUseOfDotIat) => { checker.report_diagnostic(PandasUseOfDotIat, range) } diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/future_feature_not_defined.rs b/crates/ruff_linter/src/rules/pyflakes/rules/future_feature_not_defined.rs index d99f90dd7b..f30347c0d6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/future_feature_not_defined.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/future_feature_not_defined.rs @@ -30,6 +30,7 @@ impl Violation for FutureFeatureNotDefined { } } +/// F407 pub(crate) fn future_feature_not_defined(checker: &Checker, alias: &Alias) { if is_feature_name(&alias.name) { return; diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs index 56acb220fd..a12b6a9806 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs @@ -276,6 +276,7 @@ fn find_dunder_all_exprs<'a>(semantic: &'a SemanticModel) -> Vec<&'a ast::Expr> .collect() } +/// F401 /// For some unused binding in an import statement... /// /// __init__.py ∧ 1stpty → safe, if one __all__, add to __all__ diff --git a/crates/ruff_linter/src/rules/pylint/rules/eq_without_hash.rs b/crates/ruff_linter/src/rules/pylint/rules/eq_without_hash.rs index 963bcf18a2..69401e854d 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/eq_without_hash.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/eq_without_hash.rs @@ -73,7 +73,7 @@ impl Violation for EqWithoutHash { } } -/// W1641 +/// PLW1641 pub(crate) fn object_without_hash_method(checker: &Checker, class: &StmtClassDef) { if checker.source_type.is_stub() { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs b/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs index 7a5e7ee9ce..4fc2bf484e 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs @@ -80,7 +80,7 @@ impl Violation for IfStmtMinMax { } } -/// R1730, R1731 +/// PLR1730, PLR1731 pub(crate) fn if_stmt_min_max(checker: &Checker, stmt_if: &ast::StmtIf) { let ast::StmtIf { test, diff --git a/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs b/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs index ed3434460e..40e82aa259 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs @@ -55,7 +55,7 @@ impl Violation for ImportOutsideTopLevel { } } -/// C0415 +/// PLC0415 pub(crate) fn import_outside_top_level(checker: &Checker, stmt: &Stmt) { if checker.semantic().current_scope().kind.is_module() { // "Top-level" imports are allowed diff --git a/crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs index dc18a2bcd9..a1ecd71cf1 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs @@ -48,7 +48,7 @@ impl Violation for InvalidHashReturnType { } } -/// E0309 +/// PLE0309 pub(crate) fn invalid_hash_return(checker: &Checker, function_def: &ast::StmtFunctionDef) { if function_def.name.as_str() != "__hash__" { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs index 5cafafdac4..dca29deb76 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs @@ -50,7 +50,7 @@ impl Violation for InvalidIndexReturnType { } } -/// E0305 +/// PLE0305 pub(crate) fn invalid_index_return(checker: &Checker, function_def: &ast::StmtFunctionDef) { if function_def.name.as_str() != "__index__" { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs index 7766332a5a..4e155a4aab 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs @@ -49,7 +49,7 @@ impl Violation for InvalidLengthReturnType { } } -/// E0303 +/// PLE0303 pub(crate) fn invalid_length_return(checker: &Checker, function_def: &ast::StmtFunctionDef) { if function_def.name.as_str() != "__len__" { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs index fe2924d35b..2484b2f74f 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs @@ -44,7 +44,7 @@ impl Violation for InvalidStrReturnType { } } -/// E0307 +/// PLE0307 pub(crate) fn invalid_str_return(checker: &Checker, function_def: &ast::StmtFunctionDef) { if function_def.name.as_str() != "__str__" { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/nonlocal_and_global.rs b/crates/ruff_linter/src/rules/pylint/rules/nonlocal_and_global.rs index ad42ac3928..bb8b10a2ea 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/nonlocal_and_global.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/nonlocal_and_global.rs @@ -53,7 +53,7 @@ impl Violation for NonlocalAndGlobal { } } -/// E115 +/// PLE0115 pub(crate) fn nonlocal_and_global(checker: &Checker, nonlocal: &ast::StmtNonlocal) { // Determine whether any of the newly declared `nonlocal` variables are already declared as // `global`. diff --git a/crates/ruff_linter/src/rules/pylint/rules/repeated_keyword_argument.rs b/crates/ruff_linter/src/rules/pylint/rules/repeated_keyword_argument.rs index f35f7b0f10..b2033a5e8f 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/repeated_keyword_argument.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/repeated_keyword_argument.rs @@ -35,6 +35,7 @@ impl Violation for RepeatedKeywordArgument { } } +/// PLE1132 pub(crate) fn repeated_keyword_argument(checker: &Checker, call: &ExprCall) { let ExprCall { arguments, .. } = call; diff --git a/crates/ruff_linter/src/rules/pylint/rules/self_or_cls_assignment.rs b/crates/ruff_linter/src/rules/pylint/rules/self_or_cls_assignment.rs index 6799396b1a..d6611acd21 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/self_or_cls_assignment.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/self_or_cls_assignment.rs @@ -66,7 +66,7 @@ impl Violation for SelfOrClsAssignment { } } -/// PLW0127 +/// PLW0642 pub(crate) fn self_or_cls_assignment(checker: &Checker, target: &Expr) { let ScopeKind::Function(ast::StmtFunctionDef { name, diff --git a/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs b/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs index c9b83fd2e8..91d280fb73 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs @@ -58,7 +58,7 @@ impl Violation for SingledispatchMethod { } } -/// E1519 +/// PLE1519 pub(crate) fn singledispatch_method(checker: &Checker, scope: &Scope) { let Some(func) = scope.kind.as_function() else { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs b/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs index ead9609e5d..eb2e82c258 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs @@ -56,7 +56,7 @@ impl Violation for SingledispatchmethodFunction { } } -/// E1520 +/// PLE1520 pub(crate) fn singledispatchmethod_function(checker: &Checker, scope: &Scope) { let Some(func) = scope.kind.as_function() else { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs index 267e59ff2a..53decdc547 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs @@ -99,7 +99,7 @@ impl Violation for TooManyPublicMethods { } } -/// R0904 +/// PLR0904 pub(crate) fn too_many_public_methods( checker: &Checker, class_def: &ast::StmtClassDef, diff --git a/crates/ruff_linter/src/rules/refurb/rules/int_on_sliced_str.rs b/crates/ruff_linter/src/rules/refurb/rules/int_on_sliced_str.rs index 7470355369..588569f397 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/int_on_sliced_str.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/int_on_sliced_str.rs @@ -64,6 +64,7 @@ impl AlwaysFixableViolation for IntOnSlicedStr { } } +/// FURB166 pub(crate) fn int_on_sliced_str(checker: &Checker, call: &ExprCall) { // Verify that the function is `int`. if !checker.semantic().match_builtin_expr(&call.func, "int") { diff --git a/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs b/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs index 351d548334..5dc94542da 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs @@ -114,6 +114,7 @@ impl PytestContextType { } } +/// RUF061 pub(crate) fn legacy_raises_warns_deprecated_call(checker: &Checker, call: &ast::ExprCall) { let semantic = checker.semantic(); let Some(context_type) = PytestContextType::from_expr_name(&call.func, semantic) else { diff --git a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_all.rs b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_all.rs index 15e0760dc2..70fd5acd6c 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_all.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_all.rs @@ -158,6 +158,7 @@ pub(crate) fn sort_dunder_all_ann_assign(checker: &Checker, node: &ast::StmtAnnA } } +/// RUF022 /// Sort a tuple or list that defines or mutates the global variable `__all__`. /// /// This routine checks whether the tuple or list is sorted, and emits a diff --git a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs index 64b7f2b86e..e626ac8535 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs @@ -105,6 +105,7 @@ impl Violation for UnsortedDunderSlots { const SORTING_STYLE: SortingStyle = SortingStyle::Natural; +/// RUF023 /// Sort a tuple, list, dict or set that defines `__slots__` in a class scope. /// /// This routine checks whether the display is sorted, and emits a diff --git a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs index 5e06dd8ad1..8e815c601b 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs @@ -74,7 +74,7 @@ impl Violation for UnnecessaryNestedLiteral { } } -/// RUF039 +/// RUF041 pub(crate) fn unnecessary_nested_literal<'a>(checker: &Checker, literal_expr: &'a Expr) { let mut is_nested = false;