Pylint JUnit Reporter
Pylint plugin that generates JUnit based report that can be consumed by CI environments like Jenkins, Azure DevOps, and similar environments. This project was created to address shortcomings in other tools at the time, specifically around handling 'empty' results (no Pylint issues) and better mapping multiple issues per file. The current version is 0.3.5, last released on January 21, 2025.
Warnings
- gotcha Older or alternative JUnit reporters for Pylint (e.g., `pylint2junit`) sometimes produced invalid XML, especially when no issues were found. `pylint-junit` was developed to specifically address these 'empty result' scenarios, ensuring valid JUnit XML is always generated.
- gotcha When configuring `pylint-junit` in your `.pylintrc` file using `output-format=junit`, it sets the default output for all Pylint runs. If you sometimes need the standard Pylint output, you should omit this from your `.pylintrc` and instead specify `--output-format=junit` (or `--output-format=pylint_junit.JUnitReporter`) on the command line only when a JUnit report is desired.
- gotcha There have been reported compatibility issues with `pylint-junit` and specific `pylint` versions, particularly `pylint 2.15` and newer at certain points. While the project aims to stay compatible, users experiencing unexpected behavior should check the GitHub issues for known compatibility problems with their specific `pylint` version.
Install
-
pip install pylint-junit
Imports
- JUnitReporter
pylint --output-format=pylint_junit.JUnitReporter your_module.py
Quickstart
import os
def check_me():
x = 1
y = 2
z = x + y
return 'result'
# To run Pylint with the JUnit reporter:
# 1. Save the above code as 'my_module.py'
# 2. Run in your terminal:
# pip install pylint pylint-junit
# pylint --output-format=pylint_junit.JUnitReporter my_module.py > pylint_report.xml
# 3. View the generated pylint_report.xml file.