Pylint: disable warning for subclass

I use pylint in the project and something bothers me.

For example, I create a unit test (subclass of unittest.TestCase). This parent class has many methods, so pylint says "R0904: Too many public methods." To "resolve" this warning, I will disable this check locally.

But I need to write a lot of unit test, and this prevents me from turning off this check locally every time.

So, I'm looking for a way to disable this check for the whole subclass of unittest.TestCase. There may be pylint in the configuration file, but I did not find anything.

Do you have an idea to do this?

Many thanks for your help.

+6
source share
1 answer

You can define the pylintrc file and run pylint using this. You can do it as follows:

 $ pylint --generate-rcfile > pylintrc 

This creates the default pylintrc file. This should have a paragraph that looks like this:

 # 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 this paragraph (but in the MESSAGE MANAGEMENT section):

 disable=R0904 

or

 disable=too-many-public-methods 

Then you need to start pylint with this rcfile. This can be done using the argument --rcfile=<file> .

+2
source

Source: https://habr.com/ru/post/975976/


All Articles