Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Airflow Root Pre Commit Config

From Leeroopedia


Knowledge Sources
Domains CI_CD, Code_Quality
Last Updated 2026-02-08 21:00 GMT

Overview

Root-level pre-commit hook configuration for the Apache Airflow monorepo, defining 30+ hooks for code quality enforcement including license headers, linting, formatting, spell checking, and security scanning.

Description

The .pre-commit-config.yaml file is a 952-line YAML configuration that defines the full set of pre-commit hooks run at the repository root level. It applies to the entire monorepo and orchestrates hooks from multiple sources:

  • External repositories:
    • eclipse-csi/octopin -- Pin versions of CI dependencies (manual stage)
    • thlorenz/doctoc -- Add table of contents to Markdown/RST files
    • Lucas-C/pre-commit-hooks -- License header insertion for SQL, RST, CSS, JS, Python, YAML, XML, Shell, TOML, Markdown, and other files
    • adamchainz/blacken-docs -- Run black formatting on documentation code blocks
    • pre-commit/pre-commit-hooks -- Standard checks (merge conflicts, debug statements, private keys, trailing whitespace, end-of-file, executables, XML validation)
    • pre-commit/pygrep-hooks -- RST backtick checks, deprecated log.warn detection
    • adrienverge/yamllint -- YAML file linting with custom config
    • ikamensh/flynt -- Convert old-style string formatting to f-strings
    • codespell-project/codespell -- Spell checking with custom wordlist
    • woodruffw/zizmor-pre-commit -- GitHub workflow syntax validation
  • Local hooks (two groups):
    • Group 1: check-min-python-version, check-notice-files, check-version-consistency, upgrade-important-versions
    • Group 2: check-shared-distributions-structure, check-shared-distributions-usage, check-airflow-imports-in-shared, check-secrets-search-path-sync, ruff (linting), ruff-format (formatting), replace-bad-characters, lint-dockerfile, check-airflow-providers-bug-report-template, update-local-yml-file, check-extras-order, generate-airflow-diagrams, prevent-deprecated-sqlalchemy-usage, update-supported-versions, check-revision-heads-map, update-version, check-pydevd-left-in-code, check-safe-filter-usage-in-html, check-urlparse-usage-in-code, check-for-inclusive-language

The configuration specifies default_stages: [pre-commit, pre-push], Python 3 as default language, Node 22.19.0, and Go 1.24.0.

Usage

Developers run these hooks automatically via git hooks or manually:

# Run all hooks on all files
pre-commit run --all-files

# Run a specific hook
pre-commit run ruff --all-files

# Run hooks on staged files only (default on commit)
pre-commit run

Code Reference

Source Location

Signature

# Root pre-commit configuration structure
default_stages: [pre-commit, pre-push]
minimum_prek_version: '0.2.22'
default_language_version:
  python: python3
  node: 22.19.0
  golang: 1.24.0
exclude: ^.*/.*_vendor/
repos:
  - repo: meta
    hooks:
      - id: identity
      - id: check-hooks-apply
  - repo: https://github.com/eclipse-csi/octopin
    # ... pin versions of CI dependencies
  - repo: https://github.com/thlorenz/doctoc.git
    # ... add TOC for Markdown/RST
  - repo: https://github.com/Lucas-C/pre-commit-hooks
    # ... license header insertion (10+ hook variants)
  - repo: local
    hooks:
      - id: check-min-python-version
      - id: check-notice-files
      - id: check-version-consistency
  - repo: https://github.com/adamchainz/blacken-docs
    # ... format code in docs
  - repo: https://github.com/pre-commit/pre-commit-hooks
    # ... standard quality checks
  - repo: https://github.com/adrienverge/yamllint
    # ... YAML linting
  - repo: https://github.com/ikamensh/flynt
    # ... f-string conversion
  - repo: https://github.com/codespell-project/codespell
    # ... spell checking
  - repo: https://github.com/woodruffw/zizmor-pre-commit
    # ... GitHub Actions security scanning
  - repo: local
    hooks:
      - id: ruff
      - id: ruff-format
      - id: check-for-inclusive-language
      # ... 20+ additional local hooks

I/O Contract

Inputs

Name Type Required Description
Staged files File list Yes Files staged for commit (or all files when run with --all-files)
File types MIME/extension No Hooks filter files by type (Python, YAML, shell, etc.)

Outputs

Name Type Description
Pass/Fail status Exit code Exit code 0 for success, non-zero for failure
Auto-fixes Modified files Some hooks automatically fix issues (ruff, license headers, formatting, TOC generation)
Error messages stderr/stdout Descriptive error messages for failed checks

Usage Examples

Running All Hooks

# Run all pre-commit hooks against all files in the repository
pre-commit run --all-files

Running a Specific Hook

# Run only the ruff linter
pre-commit run ruff --all-files

# Run only the license header check
pre-commit run insert-license --all-files

# Run codespell for spelling
pre-commit run codespell --all-files

Key Hook Categories

Category Hook IDs Description
Linting ruff, yamllint, lint-dockerfile Code and config linting
Formatting ruff-format, blacken-docs, flynt Code formatting and modernization
License insert-license (10 variants) Ensure all files have Apache 2.0 license headers
Security detect-private-key, zizmor Prevent secrets and scan workflows
Quality codespell, check-for-inclusive-language Spelling and inclusive language checks
Consistency check-version-consistency, check-revision-heads-map Cross-file version consistency

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment