2020-09-16 21:13:41 +00:00
|
|
|
# To use:
|
|
|
|
#
|
|
|
|
# pre-commit run -a
|
|
|
|
#
|
|
|
|
# Or:
|
|
|
|
#
|
|
|
|
# pre-commit install # (runs every time you commit in git)
|
|
|
|
#
|
|
|
|
# To update this file:
|
|
|
|
#
|
|
|
|
# pre-commit autoupdate
|
|
|
|
#
|
|
|
|
# See https://github.com/pre-commit/pre-commit
|
|
|
|
|
2022-10-04 18:01:26 +00:00
|
|
|
|
|
|
|
ci:
|
|
|
|
autoupdate_commit_msg: "chore(deps): update pre-commit hooks"
|
|
|
|
autofix_commit_msg: "style: pre-commit fixes"
|
|
|
|
autoupdate_schedule: monthly
|
|
|
|
|
2022-08-09 04:02:45 +00:00
|
|
|
# third-party content
|
|
|
|
exclude: ^tools/JoinPaths.cmake$
|
|
|
|
|
2020-07-20 17:35:21 +00:00
|
|
|
repos:
|
2023-06-16 21:09:40 +00:00
|
|
|
|
|
|
|
# Clang format the codebase automatically
|
|
|
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
2024-05-24 16:26:40 +00:00
|
|
|
rev: "v18.1.5"
|
2023-06-16 21:09:40 +00:00
|
|
|
hooks:
|
|
|
|
- id: clang-format
|
|
|
|
types_or: [c++, c, cuda]
|
|
|
|
|
2023-11-08 07:42:54 +00:00
|
|
|
# Ruff, the Python auto-correcting linter/formatter written in Rust
|
2023-07-04 12:38:14 +00:00
|
|
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
2024-06-06 21:08:18 +00:00
|
|
|
rev: v0.4.7
|
2023-06-16 21:09:40 +00:00
|
|
|
hooks:
|
|
|
|
- id: ruff
|
|
|
|
args: ["--fix", "--show-fixes"]
|
2023-11-08 07:42:54 +00:00
|
|
|
- id: ruff-format
|
2023-06-16 21:09:40 +00:00
|
|
|
|
|
|
|
# Check static types with mypy
|
|
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
2024-05-10 21:03:51 +00:00
|
|
|
rev: "v1.10.0"
|
2023-06-16 21:09:40 +00:00
|
|
|
hooks:
|
|
|
|
- id: mypy
|
|
|
|
args: []
|
|
|
|
exclude: ^(tests|docs)/
|
|
|
|
additional_dependencies:
|
2024-04-02 15:14:08 +00:00
|
|
|
- markdown-it-py
|
2023-06-16 21:09:40 +00:00
|
|
|
- nox
|
|
|
|
- rich
|
2023-06-21 17:25:10 +00:00
|
|
|
- types-setuptools
|
2023-06-16 21:09:40 +00:00
|
|
|
|
|
|
|
# CMake formatting
|
|
|
|
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
|
|
|
rev: "v0.6.13"
|
|
|
|
hooks:
|
|
|
|
- id: cmake-format
|
|
|
|
additional_dependencies: [pyyaml]
|
|
|
|
types: [file]
|
|
|
|
files: (\.cmake|CMakeLists.txt)(.in)?$
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# Standard hooks
|
2020-07-20 17:35:21 +00:00
|
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
2024-05-10 21:03:51 +00:00
|
|
|
rev: "v4.6.0"
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: check-added-large-files
|
|
|
|
- id: check-case-conflict
|
2021-09-22 19:38:50 +00:00
|
|
|
- id: check-docstring-first
|
2020-07-20 17:35:21 +00:00
|
|
|
- id: check-merge-conflict
|
|
|
|
- id: check-symlinks
|
2021-09-22 19:38:50 +00:00
|
|
|
- id: check-toml
|
2020-07-20 17:35:21 +00:00
|
|
|
- id: check-yaml
|
|
|
|
- id: debug-statements
|
|
|
|
- id: end-of-file-fixer
|
|
|
|
- id: mixed-line-ending
|
|
|
|
- id: requirements-txt-fixer
|
|
|
|
- id: trailing-whitespace
|
2021-04-20 21:34:31 +00:00
|
|
|
exclude: \.patch?$
|
2020-07-20 17:35:21 +00:00
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Also code format the docs
|
2024-05-24 16:26:40 +00:00
|
|
|
- repo: https://github.com/adamchainz/blacken-docs
|
2023-09-06 13:04:27 +00:00
|
|
|
rev: "1.16.0"
|
2021-09-22 19:38:50 +00:00
|
|
|
hooks:
|
|
|
|
- id: blacken-docs
|
|
|
|
additional_dependencies:
|
2023-11-08 07:42:54 +00:00
|
|
|
- black==23.*
|
2020-09-16 21:13:41 +00:00
|
|
|
|
|
|
|
# Changes tabs to spaces
|
2020-07-20 17:35:21 +00:00
|
|
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
2024-04-02 15:14:08 +00:00
|
|
|
rev: "v1.5.5"
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: remove-tabs
|
2021-04-20 21:34:31 +00:00
|
|
|
exclude: (^docs/.*|\.patch)?$
|
2020-07-20 17:35:21 +00:00
|
|
|
|
2023-02-22 14:18:55 +00:00
|
|
|
# Avoid directional quotes
|
2022-02-12 00:06:16 +00:00
|
|
|
- repo: https://github.com/sirosen/texthooks
|
2024-04-02 15:14:08 +00:00
|
|
|
rev: "0.6.6"
|
2022-02-12 00:06:16 +00:00
|
|
|
hooks:
|
|
|
|
- id: fix-ligatures
|
|
|
|
- id: fix-smartquotes
|
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Checking for common mistakes
|
2021-10-08 12:38:04 +00:00
|
|
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
2023-02-01 19:23:37 +00:00
|
|
|
rev: "v1.10.0"
|
2021-10-08 12:38:04 +00:00
|
|
|
hooks:
|
|
|
|
- id: rst-backticks
|
|
|
|
- id: rst-directive-colons
|
|
|
|
- id: rst-inline-touching-normal
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# Checks the manifest for missing files (native support)
|
|
|
|
- repo: https://github.com/mgedmin/check-manifest
|
2022-12-06 18:10:48 +00:00
|
|
|
rev: "0.49"
|
2020-09-16 21:13:41 +00:00
|
|
|
hooks:
|
|
|
|
- id: check-manifest
|
|
|
|
# This is a slow hook, so only run this if --hook-stage manual is passed
|
|
|
|
stages: [manual]
|
|
|
|
additional_dependencies: [cmake, ninja]
|
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Check for spelling
|
2022-08-30 04:59:48 +00:00
|
|
|
# Use tools/codespell_ignore_lines_from_errors.py
|
|
|
|
# to rebuild .codespell-ignore-lines
|
2021-07-06 21:10:35 +00:00
|
|
|
- repo: https://github.com/codespell-project/codespell
|
2024-05-24 16:26:40 +00:00
|
|
|
rev: "v2.3.0"
|
2021-07-06 21:10:35 +00:00
|
|
|
hooks:
|
|
|
|
- id: codespell
|
2021-07-14 20:49:13 +00:00
|
|
|
exclude: ".supp$"
|
2024-05-10 21:03:51 +00:00
|
|
|
args: ["-x.codespell-ignore-lines", "-Lccompiler,intstruct"]
|
2021-07-06 21:10:35 +00:00
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Check for common shell mistakes
|
2021-09-22 19:38:50 +00:00
|
|
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
2024-04-02 15:14:08 +00:00
|
|
|
rev: "v0.10.0.1"
|
2021-09-22 19:38:50 +00:00
|
|
|
hooks:
|
|
|
|
- id: shellcheck
|
2021-07-06 21:10:35 +00:00
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Disallow some common capitalization mistakes
|
2020-09-08 13:26:50 +00:00
|
|
|
- repo: local
|
|
|
|
hooks:
|
|
|
|
- id: disallow-caps
|
|
|
|
name: Disallow improper capitalization
|
|
|
|
language: pygrep
|
2023-09-27 17:22:04 +00:00
|
|
|
entry: PyBind|\bNumpy\b|Cmake|CCache|PyTest
|
2022-02-11 02:28:08 +00:00
|
|
|
exclude: ^\.pre-commit-config.yaml$
|
2020-09-08 13:26:50 +00:00
|
|
|
|
2023-06-16 21:09:40 +00:00
|
|
|
# PyLint has native support - not always usable, but works for us
|
|
|
|
- repo: https://github.com/PyCQA/pylint
|
2024-05-24 16:26:40 +00:00
|
|
|
rev: "v3.2.2"
|
2020-07-20 19:07:22 +00:00
|
|
|
hooks:
|
2023-06-16 21:09:40 +00:00
|
|
|
- id: pylint
|
|
|
|
files: ^pybind11
|
2024-02-13 23:29:42 +00:00
|
|
|
|
2024-05-24 16:26:40 +00:00
|
|
|
# Check schemas on some of our YAML files
|
2024-02-13 23:29:42 +00:00
|
|
|
- repo: https://github.com/python-jsonschema/check-jsonschema
|
2024-05-24 16:26:40 +00:00
|
|
|
rev: 0.28.4
|
2024-02-13 23:29:42 +00:00
|
|
|
hooks:
|
|
|
|
- id: check-readthedocs
|
|
|
|
- id: check-github-workflows
|
|
|
|
- id: check-dependabot
|