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
|
|
|
|
|
2020-07-20 17:35:21 +00:00
|
|
|
repos:
|
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
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v4.1.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
|
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Upgrade old Python syntax
|
2021-07-12 19:01:19 +00:00
|
|
|
- repo: https://github.com/asottile/pyupgrade
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v2.31.0"
|
2021-07-12 19:01:19 +00:00
|
|
|
hooks:
|
|
|
|
- id: pyupgrade
|
2022-02-12 00:06:16 +00:00
|
|
|
args: [--py36-plus]
|
2021-07-12 19:01:19 +00:00
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Nicely sort includes
|
2021-08-13 16:37:05 +00:00
|
|
|
- repo: https://github.com/PyCQA/isort
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "5.10.1"
|
2021-08-13 16:37:05 +00:00
|
|
|
hooks:
|
|
|
|
- id: isort
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# Black, the code formatter, natively supports pre-commit
|
|
|
|
- repo: https://github.com/psf/black
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "22.1.0" # Keep in sync with blacken-docs
|
2020-09-16 21:13:41 +00:00
|
|
|
hooks:
|
|
|
|
- id: black
|
2021-09-22 19:38:50 +00:00
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Also code format the docs
|
2021-09-22 19:38:50 +00:00
|
|
|
- repo: https://github.com/asottile/blacken-docs
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v1.12.1"
|
2021-09-22 19:38:50 +00:00
|
|
|
hooks:
|
|
|
|
- id: blacken-docs
|
|
|
|
additional_dependencies:
|
2022-02-11 02:28:08 +00:00
|
|
|
- black==22.1.0 # keep in sync with black hook
|
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
|
2022-02-15 16:27:00 +00:00
|
|
|
rev: "v1.1.12"
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: remove-tabs
|
|
|
|
|
2022-02-12 00:06:16 +00:00
|
|
|
- repo: https://github.com/sirosen/texthooks
|
|
|
|
rev: "0.2.2"
|
|
|
|
hooks:
|
|
|
|
- id: fix-ligatures
|
|
|
|
- id: fix-smartquotes
|
|
|
|
|
2021-11-14 02:32:58 +00:00
|
|
|
# Autoremoves unused imports
|
|
|
|
- repo: https://github.com/hadialqattan/pycln
|
2022-02-23 22:56:41 +00:00
|
|
|
rev: "v1.2.0"
|
2021-11-14 02:32:58 +00:00
|
|
|
hooks:
|
|
|
|
- id: pycln
|
|
|
|
|
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
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v1.9.0"
|
2021-10-08 12:38:04 +00:00
|
|
|
hooks:
|
|
|
|
- id: python-check-blanket-noqa
|
|
|
|
- id: python-check-blanket-type-ignore
|
|
|
|
- id: python-no-log-warn
|
2022-02-12 00:06:16 +00:00
|
|
|
- id: python-use-type-annotations
|
2021-10-08 12:38:04 +00:00
|
|
|
- id: rst-backticks
|
|
|
|
- id: rst-directive-colons
|
|
|
|
- id: rst-inline-touching-normal
|
|
|
|
|
2022-02-15 22:48:33 +00:00
|
|
|
# Automatically remove noqa that are not used
|
|
|
|
- repo: https://github.com/asottile/yesqa
|
|
|
|
rev: "v1.3.0"
|
|
|
|
hooks:
|
|
|
|
- id: yesqa
|
|
|
|
additional_dependencies: &flake8_dependencies
|
|
|
|
- flake8-bugbear
|
|
|
|
- pep8-naming
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# Flake8 also supports pre-commit natively (same author)
|
2021-07-20 15:29:42 +00:00
|
|
|
- repo: https://github.com/PyCQA/flake8
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "4.0.1"
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: flake8
|
|
|
|
exclude: ^(docs/.*|tools/.*)$
|
2022-02-15 22:48:33 +00:00
|
|
|
additional_dependencies: *flake8_dependencies
|
2020-07-20 19:07:22 +00:00
|
|
|
|
2022-02-15 22:48:33 +00:00
|
|
|
# PyLint has native support - not always usable, but works for us
|
|
|
|
- repo: https://github.com/PyCQA/pylint
|
|
|
|
rev: "v2.12.2"
|
2021-10-08 12:38:04 +00:00
|
|
|
hooks:
|
2022-02-15 22:48:33 +00:00
|
|
|
- id: pylint
|
|
|
|
files: ^pybind11
|
2021-10-08 12:38:04 +00:00
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# CMake formatting
|
2020-07-29 20:42:07 +00:00
|
|
|
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v0.6.13"
|
2020-07-29 20:42:07 +00:00
|
|
|
hooks:
|
|
|
|
- id: cmake-format
|
|
|
|
additional_dependencies: [pyyaml]
|
2020-08-02 03:47:47 +00:00
|
|
|
types: [file]
|
|
|
|
files: (\.cmake|CMakeLists.txt)(.in)?$
|
2020-07-29 20:42:07 +00:00
|
|
|
|
2020-10-14 18:08:41 +00:00
|
|
|
# Check static types with mypy
|
|
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v0.931"
|
2020-10-14 18:08:41 +00:00
|
|
|
hooks:
|
|
|
|
- id: mypy
|
2022-02-11 02:28:08 +00:00
|
|
|
args: [--show-error-codes]
|
|
|
|
exclude: ^(tests|docs)/
|
|
|
|
additional_dependencies: [nox, rich]
|
2020-10-14 18:08:41 +00:00
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# Checks the manifest for missing files (native support)
|
|
|
|
- repo: https://github.com/mgedmin/check-manifest
|
2021-09-22 19:38:50 +00:00
|
|
|
rev: "0.47"
|
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
|
2021-07-06 21:10:35 +00:00
|
|
|
- repo: https://github.com/codespell-project/codespell
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v2.1.0"
|
2021-07-06 21:10:35 +00:00
|
|
|
hooks:
|
|
|
|
- id: codespell
|
2021-07-14 20:49:13 +00:00
|
|
|
exclude: ".supp$"
|
|
|
|
args: ["-L", "nd,ot,thist"]
|
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
|
2022-02-12 00:06:16 +00:00
|
|
|
rev: "v0.8.0.4"
|
2021-09-22 19:38:50 +00:00
|
|
|
hooks:
|
|
|
|
- id: shellcheck
|
2021-07-14 20:52:13 +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
|
2021-07-14 20:49:13 +00:00
|
|
|
entry: PyBind|Numpy|Cmake|CCache|PyTest
|
2022-02-11 02:28:08 +00:00
|
|
|
exclude: ^\.pre-commit-config.yaml$
|
2020-09-08 13:26:50 +00:00
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
# Clang format the codebase automatically
|
2022-02-10 20:17:07 +00:00
|
|
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
2022-02-23 22:56:41 +00:00
|
|
|
rev: "v13.0.1"
|
2020-07-20 19:07:22 +00:00
|
|
|
hooks:
|
2022-02-10 20:17:07 +00:00
|
|
|
- id: clang-format
|
2022-02-23 22:56:41 +00:00
|
|
|
types_or: [c++, c, cuda]
|