Does anyone know how to extract only the pylint score for a repository?
So, assuming pylint produces the following output:
Global evaluation
-----------------
Your code has been rated at 6.67/10 (previous run: 6.67/10, +0.00)
I would like it to return a value of 6.67.
Thanks,
Seán
pylintrc and put it in the master folder; running Pylint from the command line displays the score.
Pylint. Run pylint on your code before checking in. New files shall have a Pylint score of 9 or higher. New files will not be accepted if they have a Pylint score lower than 9.
Output optionsThe simplest way to output to a file is with the --output=<filename> option. The default format for the output is raw text. You can change this by passing pylint the --output-format=<value> option. Possible values are: text , json , parseable , colorized and msvs (for Visual Studio).
If you just want the score, why not grep do the heavy work?
(py3_venv) pylint script.py | grep rated
Your code has been rated at 2.65/10 (previous run: 7.65/10, +0.00)
You can run pylint
programmatically and get to the stats
dictionary of the underlying "linter":
from pylint.lint import Run
results = Run(['test.py'], do_exit=False)
# `exit` is deprecated, use `do_exit` instead
print(results.linter.stats['global_note'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With