I'm using pylint in a project and something bother me.
For example, I create a unit test (subclass of unittest.TestCase). This parent class has a lot of method, so pylint say "R0904: Too many public methods". To "solve" this warning, I disable localy this check.
But I need to write a lot of unit test and it bothers me to disable localy this check each time.
So I'm looking for a way to disable this check for all subclass of unittest.TestCase. In a pylint config file may be, but I didn't found anything.
Have you got any idea to do that ?
Thank a lot for your help.
This may be done by adding # pylint: disable=some-message,another-one at the desired block level or at the end of the desired line of code.
you can ignore it by adding a comment in the format # pylint: disable=[problem-code] at the end of the line where [problem-code] is the value inside pylint(...) in the pylint message – for example, abstract-class-instantiated for the problem report listed above.
How do I get rid of invalid name pylint? Create an empty Python file called run-tests.py. At the top of the file, add # pylint: disable=invalid-name so that pylint won't complain about the module name.
You can define a pylintrc
file and run pylint using that. You can do that as follows:
$ pylint --generate-rcfile > pylintrc
This generates the default pylintrc file. This should have a paragraph that looks like:
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
#disable=
You want to add the following line after that paragraph (but within the MESSAGES CONTROL section):
disable=R0904
or:
disable=too-many-public-methods
You then need to run pylint with that rcfile. This can be done using the --rcfile=<file>
argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With