pep8-naming
pep8-naming copied to clipboard
False positive for N805 in a child class
$ cat -n a.py
1 # pylint: disable=missing-class-docstring, missing-module-docstring
2
3 class Foo(type):
4 pass
5
6
7 class Bar(Foo):
8 def __init__(cls):
9 super().__init__()
$ flake8 --ignore=D100,D101,D107 a.py
a.py:8:19: N805 first argument of a method should be named 'self'
PEP8: Always use cls for the first argument to class methods.
Note that pylint is correct here:
$ pylint a.py
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
pylint does significantly more to analyze code that isn't strictly available to us. Presuming the exact case you've provided, we might be able to detect this, but if Foo
were in another module, it wouldn't actually work. We have some notion of tracking parent classes already so we might be able to catch this but it's also rare enough that I feel people would be better served by adding # noqa: N805
to the line
Hmm, then maybe this check is not a suitable task for the pep8-naming?
Hmm, then maybe this check is not a suitable task for the pep8-naming?
Checking for self
? Which is right 99.99% of the time? No. It's perfectly suitable.