Hamburger Cross Icon
Linter Configured
+
Python Collector

Linter Configured + Python Collector

Guardrail Collector Beta Devex Build And Ci

Enforce Linter Configured using data collected by Python Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Ensures a Python linter is configured (ruff, flake8, or pylint). Linters catch bugs and enforce consistent code style.
Data Source: Analyze Python projects to collect build tool info, dependencies, test coverage, and CI/CD command tracking. Enforce Python-specific engineering standards.

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.

1
Python Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Linter Configured Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# 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.

Collector ci-before-command

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.

Collector ci-after-command

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.

Collector code

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.

Collector code

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.

{ } component.json From Python Collector
{
  "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.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Turn any process doc into guardrails
Book a Demo