# Note: Can't use anything in `.venv` for local hooks when commiting from VSCode GUI.
# This is because VSCode Source Control doesn't activate `.venv` before running `git
# commit`.
#
# Example script to run via "target: pwsh script.ps1"
#
#     & ./.venv/Scripts/Activate.ps1
#     foreach ($arg in $args) {
#         autoflake -i --remove-all-unused-imports --ignore-init-module-imports $arg
#     }
#
# (https://github.com/microsoft/vscode-python/issues/10165)

ci:
  autoupdate_schedule: quarterly
{% if use_dvc %}
  skip:
    - dvc-pre-commit
    - dvc-pre-push
    - dvc-post-checkout
{% endif %}


repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: "v4.4.0"
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace
  - repo: https://github.com/PyCQA/autoflake
    rev: "v2.0.1"
    hooks:
      - id: autoflake
        args: [-i, --remove-all-unused-imports, --ignore-init-module-imports]
  - repo: https://github.com/psf/black
    hooks:
      - id: black
    rev: "23.1.0"
  - repo: https://github.com/PyCQA/isort
    rev: "5.12.0"
    hooks:
      - id: isort
  - repo: https://github.com/srstevenson/nb-clean
    rev: "2.4.0"
    hooks:
      - id: nb-clean
        args:
          - --remove-empty-cells
          - --preserve-cell-metadata
          - tags
          - slideshow
          - special
          - --
  - repo: https://github.com/asottile/pyupgrade
    rev: "v3.3.1"
    hooks:
      - id: pyupgrade
        args: ["--py{{ python_version | replace('.', '') }}-plus"]
  - repo: https://github.com/asottile/blacken-docs
    rev: "1.13.0"
    hooks:
      - id: blacken-docs
        additional_dependencies: ["black==23.1.0"]
  - repo: https://github.com/DavidAnson/markdownlint-cli2
    rev: "v0.6.0"
    hooks:
      - id: markdownlint-cli2-fix
  - repo: https://github.com/ikamensh/flynt/
    rev: "0.77"
    hooks:
      - id: flynt
  - repo: https://github.com/asottile/pyupgrade
    rev: "v3.3.1"
    hooks:
      - id: pyupgrade
{% if use_dvc %}
  - repo: https://github.com/iterative/dvc
    rev: "2.45.1"
    hooks:
      - id: dvc-pre-commit
        language_version: python3
        stages:
          - commit
      - id: dvc-pre-push
        # use s3/gs/etc instead of all to only install specific cloud support
        additional_dependencies: [".[gs]"]
        language_version: python3
        stages:
          - push
      - always_run: true
        id: dvc-post-checkout
        language_version: python3
        stages:
          - post-checkout
{% endif %}
