repos:
  # Ruff mne
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.16.6
    hooks:
      - id: ruff-check
        name: ruff lint mne
        args: ["--fix"]
        files: ^mne/|^tools/
        exclude: vulture_allowlist.py
      - id: ruff-check
        name: ruff lint mne preview
        args: ["--fix", "--preview", "--select=NPY201"]
        files: ^mne/|^tools/
      - id: ruff-check
        name: ruff lint doc, tutorials, and examples
        # D103: missing docstring in public function
        # D400: docstring first line must end with period
        args: ["--ignore=D103,D400", "--fix"]
        files: ^doc/|^tutorials/|^examples/
      - id: ruff-format
        files: ^mne/|^doc/|^tutorials/|^examples/|^tools/

  # ty (type checking); deps installed by pre-commit(.ci), see [tool.ty] in
  # pyproject.toml for the checked modules and silenced rules
  - repo: https://github.com/astral-sh/ty-pre-commit
    rev: v0.0.79
    hooks:
      - id: ty
        additional_dependencies:
          - antio  # for mne/io/ant
          - curryreader  # for mne/io/curry
          - edfio  # for mne/io/edf
          - eeglabio  # for mne/io/eeglab
          - h5py  # for mne/io/snirf
          - lazy_loader  # for mne/io/__init__.py
          - matplotlib
          - mffpy  # for mne/io/egi
          - neo  # for mne/io/neuralynx
          - numpy
          - pandas  # for mne/io/base
          - pymatreader  # for mne/io/eeglab
          - pymef  # for mne/io/mef
          - quantities  # for mne/io/neuralynx
          - scipy
        args: [--no-python-downloads, --no-project]

  # Codespell
  - repo: https://github.com/codespell-project/codespell
    rev: v2.4.3
    hooks:
      - id: codespell
        additional_dependencies:
          - tomli
        files: ^mne/|^doc/|^examples/|^tutorials/|^tools/
        types_or: [python, bib, rst, inc]

  # yamllint
  - repo: https://github.com/adrienverge/yamllint.git
    rev: v1.38.0
    hooks:
      - id: yamllint
        args: [--strict, -c, .yamllint.yml]

  # rstcheck
  - repo: https://github.com/rstcheck/rstcheck.git
    rev: v6.3.0
    hooks:
      - id: rstcheck
        additional_dependencies:
          - tomli
        files: ^doc/.*\.(rst|inc)$
        # Credit is problematic because we generate an include on the fly
        # Sponsors is problematic because we preprocess that file's rST with Jinja2
        exclude: ^doc/credits/(credit|sponsors).rst$

  # sorting
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: file-contents-sorter
        files: ^ignore_words.txt
        args: ["--ignore-case"]

  - repo: https://github.com/pappasam/toml-sort
    rev: v0.24.4
    hooks:
      - id: toml-sort-fix
        files: pyproject.toml

  - repo: local  # file-contents-sorter would put every accented name after "z"
    hooks:
      - id: sort-contributor-names
        name: Sort contributor names ignoring case and accents
        language: python
        entry: ./tools/hooks/sort_contributor_names.py
        files: '^(doc/changes/names.inc|.mailmap)$'

  # zizmor
  - repo: https://github.com/woodruffw/zizmor-pre-commit
    rev: v1.30.1
    hooks:
      - id: zizmor
        args: [--fix]
        # We correctly use pull_request_trigger, and need Zizmor 2.0+ to configure the ignore
        exclude: ^.github/workflows/automerge.yml

# The following is too slow to run on local commits, so let's only run on CIs:
#
#   - repo: https://github.com/jendrikseipp/vulture
#     rev: 'v2.11'  # or any later Vulture version
#     hooks:
#       - id: vulture