Boris SABATIER
Boris SABATIER

Reputation: 79

Pylint: disable warning for subclass

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.

Upvotes: 6

Views: 2899

Answers (1)

Matthew Franglen
Matthew Franglen

Reputation: 4532

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.

Upvotes: 3

Related Questions