default_language_version:
  python: python3
exclude: 'dotnet'
ci:
  autofix_prs: true
  autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
  autoupdate_schedule: 'monthly'

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
    - id: check-added-large-files
    - id: check-ast
    - id: check-yaml
      exclude: 'website/mkdocs/mkdocs.yml'
    - id: check-toml
    - id: check-json
      exclude: |
        (?x)^(
          .devcontainer/.*devcontainer\.json |
          ^notebook/agentchat_pdf_rag/(parsed_elements|processed_elements)\.json$
        )$
    - id: check-byte-order-marker
      exclude: .gitignore
    - id: check-merge-conflict
    - id: detect-private-key
    - id: trailing-whitespace
    - id: end-of-file-fixer
    - id: no-commit-to-branch
  - repo: https://github.com/kynan/nbstripout
    rev: 0.8.1
    hooks:
      - id: nbstripout
  - repo: local
    hooks:
      - id: build-setup-scripts
        name: build setup scripts
        entry: "scripts/pre-commit-build-setup-files.sh"
        language: python
        types: [python]
        require_serial: true
        verbose: true
        additional_dependencies: ['jinja2', 'toml', 'ruff']
  - repo: local
    hooks:
      - id: lint
        name: linting and formatting
        entry: "scripts/pre-commit-lint.sh"
        language: python
        types: [python]
        require_serial: true
        verbose: true
  - repo: https://github.com/codespell-project/codespell
    rev: v2.4.1
    hooks:
      - id: codespell
        additional_dependencies:
        - tomli
        # args: ["-L", "ans,linar,nam,tread,ot,assertIn,dependin,socio-economic,Regio"]
        # ./notebook,./website/node_modules,./website/notebooks
        exclude: |
            (?x)^(
              # notebook/.* |
              notebook/agentchat_lmm_gpt-4v.ipynb |
              notebook/agentchat_graph_rag_neo4j.ipynb |
              notebook/agentchat_swarm_graphrag_telemetry_trip_planner.ipynb |
              notebook/agentchat_reasoning_agent.ipynb |
              website/node_modules/.* |
              website/notebooks/.* |
              test/agents/experimental/document_agent/pdf_parsed/Toast_financial_report.md |
              test/agents/experimental/document_agent/pdf_parsed/nvidia_10k_2024.md |
              test/agentchat/contrib/graph_rag/trip_planner_data/attractions.* |
              website/docs/user-guide/reference-agents/assets/.* |
              website/docs/user-guide/advanced-concepts/pattern-cookbook/redundant.mdx |
            )$
  # See https://jaredkhan.com/blog/mypy-pre-commit
  - repo: local
    hooks:
    - id: mypy
      name: mypy
      entry: "./scripts/pre-commit-mypy-run.sh"
      language: python
      additional_dependencies: []
      types: [python]
      # use require_serial so that script
      # is only called once per commit
      require_serial: true
      # Print the number of files as a sanity-check
      verbose: true
    - id: check-license-headers
      name: check license headers
      entry: python ./scripts/pre-commit-license-check.py
      language: python
      types: [python]
      exclude: |
        (?x)^(
          notebook/.* |
          website/.*
        )$

  # - repo: https://github.com/Yelp/detect-secrets
  #   rev: v1.5.0
  #   hooks:
  #     - id: detect-secrets
  #       args: ["--baseline", ".secrets.baseline"]
  #       exclude: |
  #         (?x)^(
  #             package.lock.json
  #         )$

  - repo: local
    hooks:
      - id: generate-devcontainer-files
        name: Generate devcontainer files
        entry: "scripts/devcontainer/generate-devcontainers.sh"
        language: python
        require_serial: true
        verbose: true
        additional_dependencies: ['jinja2']
        files: ^(scripts/devcontainer/.*)$
