False Error N805
tanducmai opened this issue · comments
N805 error says that 'first argument of a method should be named 'self'', which is True.
However, in my case, I am defining a class method which has its first argument being cls
in lieu of self
, and the error of N805 is still raised, which is not True.
According to Function and Method Arguments, 'Always use cls
for the first argument to class methods.'
Edit: my case is actually an abstract class method, I believe that is why the error is raised since it does not recognise abstract methods.
pep8-naming attempts to determine whether or not a method is an instance or class method based on the presence of a decorator (like @classmethod
) or some other reliable criteria (such as if the method is named __new__
or __init_subclass__
or within a metaclass).
You can "teach" pep8-naming about any custom class method decorators using --classmethod-decorators
.
If none of those cover your use case, then you can just suppress the lint error in this instance using # noqa: N805
.