-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 E0202 (method-hidden) #414
Comments
I'm also having the problem. Looks like pylint does not like overloading a method with 'default' as the method name. Our build system is using pylint to check code, and the result is I cannot extend the JSONEncoder class. |
I have the same problem |
Same problem. |
Workaround: |
This is indeed a false positive, but it has nothing to do with the fact that the method is called 'default' and partially, it is an oddity with the json.JSONEncoder class as well. The problem is that it can accept a default argument, which gets set into a property here https://hg.python.org/cpython/file/tip/Lib/json/encoder.py#l157, although later it also defines a default method for being overridden by subclasses. I need to think of a potential fix though. |
discussion here pylint-dev/pylint#414
I get this error too when overriding the run method of flask_script's Command class
|
Possible solutions:
Any thoughts? |
@brycepg the first one sounds like the best option in my opinion. |
by ignoring pylint E0202 due to false positive. Reference: pylint-dev/pylint#414
Disable pylint check because of pylint-dev/pylint#414
Disable pylint check because of pylint-dev/pylint#414
Disable pylint check because of pylint-dev/pylint#414
What's the status of this bug? Is there any fix likely to be implemented soon? |
We need to override the json.JSONEncoder default() method, but pylint sees this as an error - even though it's the documented approach. See here for other complaints: pylint-dev/pylint#414 See here for justification: https://docs.python.org/3/library/json.html
|
Use of disable workaround also ends up leaving one with long lines.
works but
and neither does:
|
Since the JSONEncoder class conditionally mangles default(), pylint freaks out and starts spitting out method-hidden warnings. It was supposedly fixed with pylint-dev/pylint#414, but seemingly wasn’t. This commit adds a disabler comment with an explanation.
What works is this ugly variant:
|
If you use def default(
self, # pylint: disable=E0202
o,
): The disable algorithm is based on the |
Originally reported by: Anonymous
With this code:
I have the following pylint output:
Version:
The text was updated successfully, but these errors were encountered: