0

When running Pylint from the CLI, I can get the exit code with echo $?

However, I am running Pylint from Python using the epylint module (as described in the documentation). Unfortunately, the docs do not describe how to get the exit code when running from Python. Is there a way to do this?

For reference, this is how I'm currently running the linter:

from pylint import epylint as lint

pylint_options = 'foo -E'

(pylint_stdout, pylint_stderr) = lint.py_run(pylint_options, return_std=True)

print('StdOut:')
print(pylint_stdout.getvalue())
print('StdErr:')
print(pylint_stderr.getvalue())
dEBA M
  • 457
  • 5
  • 19
  • I've never used this module, so I am reluctant to reply. However, nobody else has offered any suggestions so I'll take a stab. It is possible there is no exit code. The "pylint" command might just invoke py_run() (in process) and then look at the output and from that determine an exit code. You are assuming that py_run() forks a new process . . . do you know for sure that is even the case? – Frank Merrow Feb 05 '20 at 18:05
  • @Frank Merrow: I don't know whether py_run forks a process. So I'll look into how pylint infers the exit code. Thanks – Gophernator Feb 06 '20 at 13:56

1 Answers1

0

epylint.py has a lint function you can call instead of py_run where lint returns the exit code.

def lint(filename, options=()):
user1106281
  • 85
  • 1
  • 5