R0201

Message

Method could be a function

Description

Used when there is no reference to the class, suggesting that the method could be used as a static function instead

Explanation

If the class method does not reference any of the class attributes it may be more clear to define the method as a static function instead.

Attempt using either of the decorators @classmethod or @staticmethod

Example:

Class Foo(object):
    ...
    def bar(self, baz):
        ...
        return llama

Try instead to use:

Class Foo(object):
    ...
    @classmethod
    def bar(cls, baz):
        ...
        return llama

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License