方法应将 "self" 作为第一个参数:装饰器的 pylint 错误

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

我有一个装饰函数:

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

我正在使用 pylint 来解决 linting 错误。它给我的错误是:

Method should have "self" as first argument

我找不到解决这个问题的方法。有人知道这个错误吗?

如果我正确地描述了您要执行的操作,请将修饰函数移到 class 之外,然后使用 @-notation 将其应用到 class 中。