Search code examples
pythonpython-decoratorspylint

Method should have "self" as first argument: pylint error for decorator


I have a decorator function:

def abc(f):
    def _abc(self, *args, **kwargs):
        # some statements
        return f(self, *args, **kwargs)
    return _abc

I am using pylint to solve linting errors. It is giving me error as:

Method should have "self" as first argument

I am not able to find the solution for this. Anyone know this error?


Solution

  • If I'm correctly picturing what you're trying to do, move the decorating function outside of the class and the apply it inside the class using the @-notation.