Skip to content

no-staticmethod-decorator (PLR0203)

Derived from the Pylint linter.

Fix is always available.

This rule is unstable and in preview. The --preview flag is required for use.

What it does

Checks for the use of a staticmethod being made without the decorator.

Why is this bad?

When it comes to consistency and readability, it's preferred to use the decorator.

Example

class Foo:
    def bar(arg1, arg2): ...

    bar = staticmethod(bar)

Use instead:

class Foo:
    @staticmethod
    def bar(arg1, arg2): ...