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
|
2021-07-12 18:56:06 +00:00
|
|
|
rev: v4.0.1
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: check-added-large-files
|
|
|
|
- id: check-case-conflict
|
|
|
|
- id: check-merge-conflict
|
|
|
|
- id: check-symlinks
|
|
|
|
- id: check-yaml
|
|
|
|
- id: debug-statements
|
|
|
|
- id: end-of-file-fixer
|
|
|
|
- id: mixed-line-ending
|
|
|
|
- id: requirements-txt-fixer
|
|
|
|
- id: trailing-whitespace
|
|
|
|
- id: fix-encoding-pragma
|
2021-07-12 21:45:40 +00:00
|
|
|
exclude: ^noxfile.py$
|
2020-07-20 17:35:21 +00:00
|
|
|
|
2021-07-12 19:01:19 +00:00
|
|
|
- repo: https://github.com/asottile/pyupgrade
|
2021-07-26 19:05:58 +00:00
|
|
|
rev: v2.23.0
|
2021-07-12 19:01:19 +00:00
|
|
|
hooks:
|
|
|
|
- id: pyupgrade
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# Black, the code formatter, natively supports pre-commit
|
|
|
|
- repo: https://github.com/psf/black
|
2021-07-20 15:29:42 +00:00
|
|
|
rev: 21.7b0
|
2020-09-16 21:13:41 +00:00
|
|
|
hooks:
|
|
|
|
- id: black
|
2020-10-14 18:08:41 +00:00
|
|
|
# By default, this ignores pyi files, though black supports them
|
|
|
|
types: [text]
|
2020-10-16 20:38:13 +00:00
|
|
|
files: \.pyi?$
|
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
|
2021-07-12 18:56:06 +00:00
|
|
|
rev: v1.1.10
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: remove-tabs
|
|
|
|
|
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
|
2021-07-12 18:56:06 +00:00
|
|
|
rev: 3.9.2
|
2020-07-20 17:35:21 +00:00
|
|
|
hooks:
|
|
|
|
- id: flake8
|
2020-07-20 19:07:22 +00:00
|
|
|
additional_dependencies: [flake8-bugbear, pep8-naming]
|
2020-07-20 17:35:21 +00:00
|
|
|
exclude: ^(docs/.*|tools/.*)$
|
2020-07-20 19:07:22 +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
|
2020-09-30 19:48:08 +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
|
2021-07-12 18:56:06 +00:00
|
|
|
rev: v0.910
|
2020-10-14 18:08:41 +00:00
|
|
|
hooks:
|
|
|
|
- id: mypy
|
|
|
|
# The default Python type ignores .pyi files, so let's rerun if detected
|
|
|
|
types: [text]
|
|
|
|
files: ^pybind11.*\.pyi?$
|
|
|
|
# Running per-file misbehaves a bit, so just run on all files, it's fast
|
|
|
|
pass_filenames: false
|
2021-07-12 18:56:06 +00:00
|
|
|
additional_dependencies: [typed_ast]
|
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-01-25 21:09:36 +00:00
|
|
|
rev: "0.46"
|
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]
|
|
|
|
|
2021-07-06 21:10:35 +00:00
|
|
|
- repo: https://github.com/codespell-project/codespell
|
|
|
|
rev: v2.1.0
|
|
|
|
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
|
|
|
|
2021-07-14 20:52:13 +00:00
|
|
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
|
|
rev: v0.7.2.1
|
|
|
|
hooks:
|
|
|
|
- id: shellcheck
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
# The original pybind11 checks for a few C++ style items
|
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
|
2020-09-08 13:26:50 +00:00
|
|
|
exclude: .pre-commit-config.yaml
|
|
|
|
|
2020-07-20 19:07:22 +00:00
|
|
|
- repo: local
|
|
|
|
hooks:
|
|
|
|
- id: check-style
|
|
|
|
name: Classic check-style
|
|
|
|
language: system
|
|
|
|
types:
|
|
|
|
- c++
|
|
|
|
entry: ./tools/check-style.sh
|