Package: pylint-exit
pylint-exitUtility to handle pylint exit codes on Linux in a scripting-friendly way.Pylint uses bit-encoded exit codes to convey the results of the pylint review,
which means it will return with a non-zero return code even when the
pylint scoring was successful.This can make it difficult to script the execution of pylint while at the same time
detecting genuine errors.pylint-exitis a small command-line utility that can be used to re-process
the pylint return code and translate it into a scripting-friendly return code.pylint-exitwill decode the bit-encoded return code, identify whether there were
any fatal messages issued (which might constitute a failure in the execution of
pylint), or a usage error, and return a0or1return code that is more easily
used in shell scripts.InstallationThe simplest way to install is viapip.pipinstallpylint-exitThis will install the package, and will provide thepylint-exitcommand line utility.You can also manually install by downloadingpylint_exit.py, and make it executable.curl-opylint-exithttps://raw.githubusercontent.com/jongracecox/pylint-exit/master/pylint_exit.py&&chmod+xpylint_exit.pyYou should also consider creating a symbolic link so that the calls in the remainder of this
README work as described.  Update<path-to>with where you downloaded the script.ln-s<path-to>/pylint_exit.py/usr/local/bin/pylint-exitNote: If you perform a--userinstall withpipthen you will need to ensure~/.local/binappears in yourPATHenvironment variable, otherwise the command linepylint-exitwill not work.UsageAdd|| pylint-exit $?to the end of your existing Pylint command.  You can then
use the updated$?return code in your shell script.pylintmymodule.py||pylint-exit$?if[$?-ne0];thenecho"An error occurred while running pylint.">&2exit1fiNote: Many CI tools will check the return code of each command, so it may be enough to
simply add|| pylint-exit $?, and leave the return code check to the CI executor.You can also use the python code directly if needed:pylintmymodule.py||pythonpylint_exit.py$?Return codesPylint can return combinations of the following codes.pylint-exitwill identify each
issued message, and return the maximum final return code.Pylint codeMessageFinal return code1Fatal message issued12Error message issued04Warning message issued08Refactor message issued016Convention message issued032Usage error1This list is stored inexit_codes_list, which can be customised if needed.You can control what is considered a failure using the following command line arguments.
By default these types of messages don't cause a non-zero return code. Adding
any of these arguments will trigger a non-zero return code when those types of
message are raised.NameMeaning-efail,--error-failFail on issued error messages.-wfail,--warn-failFail on issued warning messages.-rfail,--refactor-failFail on issued refactor messages.-cfail,--convention-failFail on issued convension messages.ExamplesExiting gracefully on non-severe messagesIn this example pylint issues refactor and convention messages, and exits with a
return code of 24.pylint-exitdecodes this, displays the messages, and exits
with a return code of 0.>pylint--rcfile=.pylintrc--output-format=textmymodule.py||pylint-exit$?Thefollowingmessageswereraised:-refactormessageissued-conventionmessageissued

Nofatalmessagesdetected.Exitinggracefully...
>echo$?0Exiting with an error on severe messagesIn this example pylint returns with a usage error due to the bad output format, and
exits with a return code of 32.pylint-exitdetects this, displays the message, and
returns with an exit code of 1.>pylint--rcfile=.pylintrc--output-format=badformatmymodule.py||pylint-exit$?Thefollowingmessageswereraised:-usageerror

Fatalmessagesdetected.Failing...
>echo$?1Treating errors and warnings as severeIn this example we will use the--error-failand--warn-failcommand line arguments
to cause pylint-exit to treat errors and warnings as serious enough to return a non-zero
return code.In the example scenario pylint issues error and warning messages, and exits with a
return code of 6.pylint-exitdecodes this, displays the messages, and exits
with a return code of 1 because the error and warning messages are now considered as
fatal.>pylint--rcfile=.pylintrc--output-format=badformatmymodule.py||pylint-exit--error-fail--warn-fail$?Thefollowingmessageswereraised:-errormessageissued-warningmessageissued

Fatalmessagesdetected.Failing...
>echo$?1TestingYou can test how pylint-exit will react to various return codes using the following command:(exit6)||pylint-exit$?or if you are using the python code directly:(exit6)||pythonpylint_exit.py$?