Pylint Exit Code Handler

1.2.0 · active · verified Fri Apr 17

Pylint-exit is a utility that wraps the `pylint` command, providing enhanced control over its exit codes. It allows users to define which `pylint` message types (e.g., errors, warnings, refactors) should result in a non-zero exit code, which is crucial for CI/CD pipelines. The current version is 1.2.0, with releases typically tied to significant `pylint` changes or feature additions.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates installing `pylint` and `pylint-exit`, then running `pylint-exit` against a sample file. It shows how to use the `--fatal-message` argument to specify which pylint message types should cause a non-zero exit code.

pip install pylint pylint-exit

# Create a sample file with pylint errors/warnings
with open('my_code.py', 'w') as f:
    f.write('def my_func():\n    x = 1  # Unused variable\n    return x + "string" # Type error\n')

# Run pylint-exit, treating 'E' (Error) messages as fatal
print("\n--- Running pylint-exit (E fatal) ---")
import subprocess
result = subprocess.run(['pylint-exit', '--fatal-message=E', 'my_code.py'], capture_output=True, text=True)
print(f"Exit Code: {result.returncode}")
print(result.stdout)
print(result.stderr)

# Run pylint-exit, treating 'W' (Warning) messages as fatal (will fail for unused variable)
print("\n--- Running pylint-exit (W fatal) ---")
result = subprocess.run(['pylint-exit', '--fatal-message=W', 'my_code.py'], capture_output=True, text=True)
print(f"Exit Code: {result.returncode}")
print(result.stdout)
print(result.stderr)

view raw JSON →