-3
  1. Why does pylint give an option to silent run I dont understand. The documentation doesnt providde reason for the same.
  2. Also, does anyone know how can one generate .pylintrc file by running a python program. I know that it can be generated from command prompt. I just wanted to know how to generate the same by running a python program.
rahul rachh
  • 99
  • 1
  • 12

1 Answers1

1

As stated in the User Guide you can run pylint from a python script using:

import pylint.lint
pylint_opts = ['--version']
pylint.lint.Run(pylint_opts)

# or
from pylint import epylint as lint
(pylint_stdout, pylint_stderr) = lint.py_run('module_name.py', return_std=True)

from the linked page

Then you can just pass in the --generate-rcfile option.

As for your first question, please clarify the silent run?

Edit: My understanding is that the "silent" run is not so silent (as in no output). It is just a different way of running pylint with no exit code. However you get the standard out and standard error as return values which is almost equivalent of what you get in the other run modes. You can then work with these outputs and parse them or store them somewhere etc.

schneebuzz
  • 348
  • 1
  • 2
  • 10
  • Thanks! I got my 2nd question answered. However, when we run the second program after the #or in the above snippet, we dont get any output and this is the code for the silent run. If you look at the documentation in the above mentioned [link](http://pylint.pycqa.org/en/latest/user_guide/run.html#invoking-pylint) , it is stated that __To silently run Pylint on a module_name.py module, and get its standard output and error:__ `from pylint import epylint as lint (pylint_stdout, pylint_stderr) = lint.py_run('module_name.py', return_std=True)` What is the significance of this ? – rahul rachh Jan 30 '20 at 13:06