Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Oct 30, 2023
1 parent 33803fa commit 7755784
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ use crate::checkers::ast::Checker;
/// ## Why is this bad?
/// When it comes to consistency and readability, it's preferred to use the decorator.
///
/// ## Example
/// ```python
/// class Foo:
/// def bar(cls):
/// ...
///
/// bar = classmethod(bar)
/// ```
///
/// Use instead:
/// ```python
/// class Foo:
/// @classmethod
/// def bar(cls):
/// ...
/// ```
#[violation]
pub struct NoClassmethodDecorator;

Expand All @@ -34,6 +50,22 @@ impl AlwaysFixableViolation for NoClassmethodDecorator {
/// ## Why is this bad?
/// When it comes to consistency and readability, it's preferred to use the decorator.
///
/// ## Example
/// ```python
/// class Foo:
/// def bar(cls):
/// ...
///
/// bar = staticmethod(bar)
/// ```
///
/// Use instead:
/// ```python
/// class Foo:
/// @staticmethod
/// def bar(cls):
/// ...
/// ```
#[violation]
pub struct NoStaticmethodDecorator;

Expand Down

0 comments on commit 7755784

Please sign in to comment.