no-classmethod-decorator / R0202ΒΆ

Message emitted:

Consider using a decorator instead of calling classmethod

Description:

Used when a class method is defined without using the decorator syntax.

Problematic code:

class Fruit:
    COLORS = []

    def __init__(self, color):
        self.color = color

    def pick_colors(cls, *args):
        """classmethod to pick fruit colors"""
        cls.COLORS = args

    pick_colors = classmethod(pick_colors)  # [no-classmethod-decorator]

Correct code:

class Fruit:
    COLORS = []

    def __init__(self, color):
        self.color = color

    @classmethod
    def pick_colors(cls, *args):
        """classmethod to pick fruit colors"""
        cls.COLORS = args

Created by the classes checker.