# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: ".git|.venv"
default_stages: [pre-commit]

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: detect-private-key
      - id: fix-byte-order-marker
      - id: debug-statements
      - id: check-ast
      - id: check-yaml
      - id: check-json
      - id: check-toml
      - id: check-xml
      - id: check-symlinks
      - id: check-case-conflict
      - id: check-merge-conflict
      - id: check-docstring-first
      - id: check-executables-have-shebangs

  # ruff and pyrefly run through `uv run` so the hook always uses the version from uv.lock
  # (a pinned ruff-pre-commit rev drifts from `uv run ruff` and the two disagree on formatting).
  # Mirrors the official ruff-pre-commit hook definition: --force-exclude + require_serial.
  - repo: local
    hooks:
      - id: ruff-check
        name: ruff check
        entry: uv run ruff check --force-exclude --fix --preview
        language: system
        types_or: [python, pyi]
        require_serial: true
        # exclude: "^legacy/"  # dirs that --fix would rewrite on touch; clean them in a separate pass
      - id: ruff-format
        name: ruff format
        entry: uv run ruff format --force-exclude
        language: system
        types_or: [python, pyi]
        require_serial: true
      - id: pyrefly-check
        name: pyrefly-check
        entry: uv run pyrefly check
        language: system
        pass_filenames: false
        types: [python]
