1

I use Python 3.3, Windows, installed pylint via pip tool.
I can run such command via "Scripts\pylint.exe" tool (parameters important, i need special plaintext output)

pylint --msg-template="{line}:{column}:{msg_id}: {msg}" --module-rgx=.* --reports=n --persistent=n "D:\TestLint\sample_plugin.py"

This checks my file and gives such output

************* Module sample_plugin
1:0:C0111: Missing module docstring
1:0:F0401: Unable to import 'tst'
3:0:W0232: Class has no __init__ method
3:0:C0111: Missing class docstring
3:0:C1001: Old-style class defined.
4:4:C0111: Missing method docstring

Now I want to use pylint via Python code, not using any EXE tools. And want to have similar/same output for my test files. So question. What Py script can I write to call pylint and get same output (in string or list)?

Prog1020
  • 4,530
  • 8
  • 31
  • 65

1 Answers1

2

There are several way to do so. The simplest being:

from pylint.lint import Run
Run([file_or_module, '--message-template', '...'])

If you want to run pylint in a subprocess (recommended for multiple runs), try:

from pylint.epylint import lint
lint(file_or_module, [--message-template', '...']
sthenault
  • 14,397
  • 5
  • 38
  • 32