When running Pylint on my file I am getting the following message.
refactor (R0915, too-many-statements, function) Too many statements (95/50)
I want to set the number of statements a function can have to 100 instead of 50 in order avoid the above message from Pylint.
Pylint works based on configured settings which are default PEP 8 standards. Now, if customizing them is good or bad can be taken for another discussion, as they are kept like that for a reason. For example, if you have a method with more than 50 lines of code, it simply means that you are increasing the cyclomatic-cognitive complexities as well as making it difficult to unit test and get coverage.
OK, arguments aside, I think the following approach can help you customize the linting rule.
Go to your Python site-packages
directory (it might be inside the Python installation Libs
folder or in your virtual environment.
For example, D:\Python37\Lib\site-packages
Open a command line here, and navigate to the Pylint directory. Execute the configuration generator like
pylint --generate-rcfile > custom_standard.rc
Now you will have a file named custom_standard.rc
in the folder. Let’s copy it to some place around your project, say, D:\lint_config\custom_standard.rc
.
Open the configuration file. You can see a setting for most of the rules. Now, for your question of number of statements inside a method, find the setting called
max-statements=50
Change it to:
max-statements=100
Save the configuration file. Now when you run the Pylint executable, use the option --rcfile
to specify your custom configuration:
pylint --rcfile=D:\lint_config\custom_standard.rc prject_dir
If you want to integrate this with your IDE like PyCharm there are plugins which allows configuring the same.
But again!, it is not a good decision to change the PEP 8 :-)