cpython/.pre-commit-config.yaml

repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.7.1
    hooks:
      - id: ruff
        name: Run Ruff (lint) on Doc/
        args: [--exit-non-zero-on-fix]
        files: ^Doc/
      - id: ruff
        name: Run Ruff (lint) on Lib/test/
        args: [--exit-non-zero-on-fix]
        files: ^Lib/test/
      - id: ruff
        name: Run Ruff (lint) on Tools/build/check_warnings.py
        args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
        files: ^Tools/build/check_warnings.py
      - id: ruff
        name: Run Ruff (lint) on Argument Clinic
        args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
        files: ^Tools/clinic/|Lib/test/test_clinic.py
      - id: ruff-format
        name: Run Ruff (format) on Doc/
        args: [--check]
        files: ^Doc/

  - repo: https://github.com/psf/black-pre-commit-mirror
    rev: 24.10.0
    hooks:
      - id: black
        name: Run Black on Tools/build/check_warnings.py
        files: ^Tools/build/check_warnings.py
        language_version: python3.12
        args: [--line-length=79]
      - id: black
        name: Run Black on Tools/jit/
        files: ^Tools/jit/
        language_version: python3.12

  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: check-case-conflict
      - id: check-merge-conflict
      - id: check-toml
        exclude: ^Lib/test/test_tomllib/
      - id: check-yaml
      - id: end-of-file-fixer
        types: [python]
        exclude: Lib/test/tokenizedata/coding20731.py
      - id: trailing-whitespace
        types_or: [c, inc, python, rst]

  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.29.4
    hooks:
      - id: check-dependabot
      - id: check-github-workflows

  - repo: https://github.com/rhysd/actionlint
    rev: v1.7.4
    hooks:
      - id: actionlint

  - repo: https://github.com/sphinx-contrib/sphinx-lint
    rev: v1.0.0
    hooks:
      - id: sphinx-lint
        args: [--enable=default-role]
        files: ^Doc/|^Misc/NEWS.d/

  - repo: local
    hooks:
      - id: blurb-no-space-c-api
        name: Check C API news entries
        language: fail
        entry: Space found in path, move to Misc/NEWS.d/next/C_API/
        files: Misc/NEWS.d/next/C API/20.*.rst

  - repo: local
    hooks:
      - id: blurb-no-space-core-and-builtins
        name: Check Core and Builtins news entries
        language: fail
        entry: Space found in path, move to Misc/NEWS.d/next/Core_and_Builtins/
        files: Misc/NEWS.d/next/Core and Builtins/20.*.rst

  - repo: meta
    hooks:
      - id: check-hooks-apply
      - id: check-useless-excludes