pylint-gitlab
pylint-gitlab provides custom Pylint formatters for seamless integration with GitLab CI/CD, enabling the generation of Code Quality reports and GitLab Pages HTML reports from Pylint's linting results. The current version is 2.1.1, released in November 2025, and the project has an active, though somewhat irregular, release cadence.
Warnings
- breaking The official GitHub repository for pylint-gitlab is archived, with a recommendation to migrate to 'ruff' for GitLab Code Quality reports. While the PyPI package still receives updates, active development for new features or bug fixes may be limited, and users are encouraged to evaluate 'ruff' as an alternative.
- gotcha When running Pylint in CI/CD, 'Unable to import' errors are common if Python dependencies are not properly installed or if the project's root is not on the `PYTHONPATH`. Pylint needs to correctly resolve imports to analyze code.
- gotcha Using `--exit-zero` with Pylint in CI prevents the job from failing due to linting errors, allowing the Code Quality report to be generated even if issues are found. Without it, the CI job might fail prematurely, preventing the report from being processed by GitLab.
- gotcha For GitLab to display Code Quality results, the generated `codeclimate.json` file must be declared as a `codequality` report artifact in your `.gitlab-ci.yml` file. Failing to do so will result in the report not appearing in merge requests.
- gotcha Pylint (a core dependency) has specific Python version requirements (e.g., Pylint 3.x generally requires Python 3.10+). Ensure that the Python version used in your CI environment is compatible with the version of Pylint being installed (which `pylint-gitlab` will pull as a dependency).
Install
-
pip install pylint-gitlab
Imports
- GitlabCodeClimateReporter
from pylint_gitlab import GitlabCodeClimateReporter
- GitlabPagesHtmlReporter
from pylint_gitlab import GitlabPagesHtmlReporter
Quickstart
# .gitlab-ci.yml
image: python:3.9-slim
pylint_job:
stage: test
before_script:
- pip install pylint-gitlab
- mkdir -p public # For HTML report if used
script:
- |-
# Create a dummy Python file to lint
echo "def func():\n x = 1\n return x" > my_module.py
# Run pylint with the GitLab Code Climate reporter
pylint --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter my_module.py > codeclimate.json
artifacts:
reports:
codequality: codeclimate.json