diff --git a/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs b/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs index 1be5e7d637..eed411f123 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs @@ -15,7 +15,7 @@ use crate::{checkers::ast::Checker, rules::flake8_unused_arguments::helpers}; /// /// ## Why is this bad? /// Unused `self` parameters are usually a sign of a method that could be -/// replaced by a function or a static method. +/// replaced by a function, class method, or static method. /// /// ## Example /// ```python @@ -26,10 +26,8 @@ use crate::{checkers::ast::Checker, rules::flake8_unused_arguments::helpers}; /// /// Use instead: /// ```python -/// class Person: -/// @staticmethod -/// def greeting(): -/// print("Greetings friend!") +/// def greeting(): +/// print("Greetings friend!") /// ``` #[violation] pub struct NoSelfUse { @@ -40,7 +38,7 @@ impl Violation for NoSelfUse { #[derive_message_formats] fn message(&self) -> String { let NoSelfUse { method_name } = self; - format!("Method `{method_name}` could be a function or static method") + format!("Method `{method_name}` could be a function, class method, or static method") } } diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap index 3b45a59ad6..85675b6d9f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -no_self_use.py:7:28: PLR6301 Method `developer_greeting` could be a function or static method +no_self_use.py:7:28: PLR6301 Method `developer_greeting` could be a function, class method, or static method | 6 | class Person: 7 | def developer_greeting(self, name): # [no-self-use] @@ -9,7 +9,7 @@ no_self_use.py:7:28: PLR6301 Method `developer_greeting` could be a function or 8 | print(f"Greetings {name}!") | -no_self_use.py:10:20: PLR6301 Method `greeting_1` could be a function or static method +no_self_use.py:10:20: PLR6301 Method `greeting_1` could be a function, class method, or static method | 8 | print(f"Greetings {name}!") 9 | @@ -18,7 +18,7 @@ no_self_use.py:10:20: PLR6301 Method `greeting_1` could be a function or static 11 | print("Hello!") | -no_self_use.py:13:20: PLR6301 Method `greeting_2` could be a function or static method +no_self_use.py:13:20: PLR6301 Method `greeting_2` could be a function, class method, or static method | 11 | print("Hello!") 12 |