# To run all pre-commit checks, use:
#
#     pre-commit run -a
#
# To install pre-commit hooks that run every time you commit:
#
#     pre-commit install
#

ci:
  autoupdate_commit_msg: "⬆️🪝 update pre-commit hooks"
  autofix_commit_msg: "🎨 pre-commit fixes"
  skip: [mypy]

repos:
  # Standard hooks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: check-added-large-files
      - id: check-case-conflict
      - id: check-docstring-first
      - id: check-merge-conflict
      - id: check-toml
      - id: check-yaml
      - id: debug-statements
      - id: end-of-file-fixer
      - id: mixed-line-ending
      - id: trailing-whitespace

  # Clean jupyter notebooks
  - repo: https://github.com/srstevenson/nb-clean
    rev: 3.3.0
    hooks:
      - id: nb-clean
        args:
          - --remove-empty-cells
          - --preserve-cell-metadata
          - raw_mimetype
          - --

  # Handling unwanted unicode characters
  - repo: https://github.com/sirosen/texthooks
    rev: 0.6.7
    hooks:
      - id: fix-ligatures
      - id: fix-smartquotes

  # Check for common mistakes
  - repo: https://github.com/pre-commit/pygrep-hooks
    rev: v1.10.0
    hooks:
      - id: rst-backticks
      - id: rst-directive-colons
      - id: rst-inline-touching-normal

  # Python linting and formatting using ruff
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.6.9
    hooks:
      - id: ruff
        args: ["--fix", "--show-fixes"]
      - id: ruff-format

  # Also run Black on examples in the documentation
  - repo: https://github.com/adamchainz/blacken-docs
    rev: 1.19.0
    hooks:
      - id: blacken-docs
        additional_dependencies: [black==24.*]

  # Format configuration files with prettier
  - repo: https://github.com/rbubley/mirrors-prettier
    rev: v3.3.3
    hooks:
      - id: prettier
        types_or: [yaml, markdown, html, css, scss, javascript, json]

  # Check static types with mypy
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy
        files: ^(src/mqt|test/python)
        args: []
        additional_dependencies:
          - pytket_qiskit
          - qiskit_optimization
          - qiskit_nature
          - qiskit_finance
          - importlib_resources
          - pytest
          - types-setuptools
          - types-requests
          - types-tqdm
          - types-flask

  # Check for spelling
  - repo: https://github.com/crate-ci/typos
    rev: v1.26.0
    hooks:
      - id: typos
        exclude: legal.html

  # Catch common capitalization mistakes
  - repo: local
    hooks:
      - id: disallow-caps
        name: Disallow improper capitalization
        language: pygrep
        entry: PyBind|Numpy|Cmake|CCache|Github|PyTest|Mqt|Tum
        exclude: .pre-commit-config.yaml

  # Check best practices for scientific Python code
  - repo: https://github.com/scientific-python/cookie
    rev: 2024.08.19
    hooks:
      - id: sp-repo-review
        additional_dependencies: ["repo-review[cli]"]

  # Check JSON schemata
  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.29.3
    hooks:
      - id: check-dependabot
      - id: check-github-workflows
      - id: check-readthedocs

  # Check the pyproject.toml file
  - repo: https://github.com/henryiii/validate-pyproject-schema-store
    rev: 2024.10.07
    hooks:
      - id: validate-pyproject
