repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
        exclude: docs/modules/python
        files: ^enterprise/
      - id: end-of-file-fixer
        exclude: docs/modules/python
        files: ^enterprise/
      - id: check-yaml
        files: ^enterprise/
      - id: debug-statements
        files: ^enterprise/
  - repo: https://github.com/abravalheri/validate-pyproject
    rev: v0.16
    hooks:
      - id: validate-pyproject
        types: [toml]
        files: ^enterprise/pyproject\.toml$

  - repo: https://github.com/astral-sh/ruff-pre-commit
    # Ruff version.
    rev: v0.4.1
    hooks:
      # Run the linter.
      - id: ruff
        entry: ruff check --config enterprise/dev_config/python/ruff.toml
        types_or: [python, pyi, jupyter]
        args: [--fix]
        files: ^enterprise/
      # Run the formatter.
      - id: ruff-format
        entry: ruff format --config enterprise/dev_config/python/ruff.toml
        types_or: [python, pyi, jupyter]
        files: ^enterprise/

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.9.0
    hooks:
      - id: mypy
        additional_dependencies:
          - types-requests
          - types-setuptools
          - types-pyyaml
          - types-toml
          - types-redis
          - lxml
          # OpenHands package in repo root
          - ./
          - stripe==11.5.0
          - pygithub==2.6.1
          - openhands-sdk==1.22.1
          - openhands-tools==1.22.1
          - sqlalchemy>=2.0
        # Use -p (package) to avoid dual module name conflict when using MYPYPATH
        # MYPYPATH=enterprise allows resolving bare imports like "from integrations.xxx"
        # Note: tests package excluded to avoid conflict with core openhands tests
        entry: bash -c 'MYPYPATH=enterprise mypy --config-file enterprise/dev_config/python/mypy.ini -p integrations -p server -p storage -p sync'
        always_run: true
        pass_filenames: false
        files: ^enterprise/
