Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for N805 in a child class #193

Open
skirpichev opened this issue Feb 5, 2022 · 3 comments
Open

False positive for N805 in a child class #193

skirpichev opened this issue Feb 5, 2022 · 3 comments

Comments

@skirpichev
Copy link

$ 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)
@sigmavirus24
Copy link
Member

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

@skirpichev
Copy link
Author

Hmm, then maybe this check is not a suitable task for the pep8-naming?

@sigmavirus24
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants