default_install_hook_types:
  - pre-commit
  - pre-push

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.3.0
    hooks:
      - id: no-commit-to-branch
        args: [--branch, main]
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.14.8
    hooks:
      - id: ruff-check
        language_version: python3
        args: [--fix, --exit-non-zero-on-fix, --show-fixes]
      - id: ruff-format
  - repo: https://github.com/codespell-project/codespell
    rev: v2.4.1
    hooks:
      - id: codespell
        additional_dependencies:
          - tomli
        exclude: package-lock.json|_vendor/.*|docs/styles/.*
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.14.1
    hooks:
      - id: mypy
        additional_dependencies:
          - pydantic>=1.10.0,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0
          - types-cachetools==5.3.0.5
          - types-pyyaml==6.0.12.9
        files: |
          (?x)^(
            src/prefect/server/models/.*|
            src/prefect/concurrency/.*|
            src/prefect/events/.*|
            src/prefect/input/.*
          )$
  - repo: https://github.com/astral-sh/uv-pre-commit
    # uv version.
    rev: 0.6.17
    hooks:
      - id: uv-lock

  - repo: local
    hooks:
      - id: check-ui-v2
        name: Check UI v2
        language: system
        entry: sh
        args:
          [
            "-c",
            ". $NVM_DIR/nvm.sh || true && cd ui-v2 && nvm use || true && npm i --no-upgrade --silent --no-progress && npm run check:staged",
          ]
        files: |
          (?x)^(
              .pre-commit-config.yaml|
              ui-v2/.*
          )$
        pass_filenames: false
      - id: service-sync-ui-v2-openapi
        name: Sync UI v2 OpenAPI
        language: system
        entry: sh
        args:
          [
            "-c",
            ". $NVM_DIR/nvm.sh || true && cd ui-v2 && nvm use || true && npm i --no-upgrade --silent --no-progress && npm run service-sync",
          ]
        files: |
          (?x)^(
              .pre-commit-config.yaml|
              .pre-commit-config.yaml|
              src/prefect/server/api/.*|
              src/prefect/server/schemas/.*|
              src/prefect/server/events/.*|
              src/prefect/server/utilities/schemas/.*|
              ui-v2/package.json
          )$
        pass_filenames: false
        stages:
          - pre-push
