-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
staticmethod causes wrong arguments-differ #7556
Comments
IIUC the example you present here violates LSP, as D can't be substituted for C's contract: >>> C.meth()
>>> D.meth()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: D.meth() missing 1 required positional argument: 'self' More discussion at #6865 (for the reverse scenario that does not violate LSP). It sounds like you wish to disable |
There are valid uses for In my mind it's PyLint that warns about methods that do not use Local disables cannot be used to annotate the one in the base class, or can they?
|
No, but I believe you could disable the message for part of the module, right before the base class, and then enable it again after all of your subclasses. (If the idea is to not have disables on each subclass.) See: https://pylint.pycqa.org/en/latest/user_guide/messages/message_control.html |
Bug description
The argument parsing mishandles uses of staticmethod in base classes for methods and miscounts the arguments, considering self extra.
Code is
Since staticmethods are faster to call, I have this frequently mixed and only use non-staticmethods where absolutely necessary. Base class implementations are often pessimistic and return None, False, do nothing etc.
Configuration
Command used
Pylint output
Expected behavior
Should not give that warning.
Pylint version
OS / Environment
Debian Buster with PyPI packages, likely irrelevant
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: