Search code examples
pythonpython-3.xlintpylintpylintrc

While using pylint I found that it also has an option of silent run. Why is it there and what is the use of it?


  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.

Solution

  • 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.