Linter Configured + Python Collector
Enforce Linter Configured using data collected by Python Collector. Automatically check devex build and ci standards on every PR.
How Python Collector Powers This Guardrail
The Python Collector gathers metadata from your languages, build systems. This data flows into Lunar's Component JSON, where the Linter Configured guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the Python Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/python@v1.0.0
# with: ...
# Step 2: Enable the Python Project Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/python@v1.0.0
include: [linter-configured]
# with: ...
What Python Collector Collects
This collector gathers the following data that the Linter Configured guardrail evaluates.
cicd
Records every Python/pip/poetry/uv command executed in CI pipelines along with the Python version. Writes command strings and version info to .lang.python.cicd for audit trails and build reproducibility analysis.
test-coverage
Extracts coverage percentage from coverage.xml (pytest-cov output) after test runs complete. Parses the XML coverage report and writes results to .lang.python.tests.coverage and .testing.coverage.
project
Analyzes Python project structure by detecting pyproject.toml, requirements.txt, setup.py, Pipfile, lockfiles, and linter/type-checker configuration. Extracts the Python version and build systems. Writes project metadata to .lang.python.
dependencies
Extracts direct dependencies from requirements.txt and pyproject.toml. Captures package name and version for each dependency. Writes the dependency list to .lang.python.dependencies.
Example Data Flow
Here's an example of the data that Python Collector writes to the Component JSON, which Linter Configured then evaluates.
{
"lang": {
"python": {
"version": "3.12.1",
"build_systems": ["poetry"],
"pyproject_exists": true,
"requirements_txt_exists": false,
"setup_py_exists": false,
"pipfile_exists": false,
"poetry_lock_exists": true,
"pipfile_lock_exists": false,
"python_version_file_exists": true,
"linter_configured": true,
"linter": "ruff",
"type_checker_configured": true,
"type_checker": "mypy",
"source": { "tool": "python", "integration": "code" },
"cicd": {
"cmds": [{ "cmd": "pytest --cov=src", "version": "3.12.1" }],
"source": { "tool": "python", "integration": "ci" }
},
"tests": {
"coverage": {
"percentage": 85.5,
"source": { "tool": "coverage", "integration": "ci" }
}
},
"dependencies": {
"direct": [
{ "path": "flask", "version": "3.0.0", "indirect": false }
],
"transitive": [],
"source": { "tool": "pip", "integration": "code" }
}
}
},
"testing": {
"coverage": {
"percentage": 85.5,
"source": { "tool": "coverage", "integration": "ci" }
},
"source": { "tool": "pytest", "integration": "ci" }
}
}
Configuration Options
Python Project Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_python_version |
Optional |
3.9
|
Minimum required Python version (e.g., "3.9", "3.11") |
min_python_version_cicd |
Optional |
3.9
|
Minimum required Python version for CI/CD commands |
Ready to Automate Your Standards?
See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.