blob: 71513c991cacf85399da96f4c94b174c332c6d7c [file] [log] [blame]
Henry Schreinerfd61f502020-09-16 17:13:41 -04001# To use:
2#
3# pre-commit run -a
4#
5# Or:
6#
7# pre-commit install # (runs every time you commit in git)
8#
9# To update this file:
10#
11# pre-commit autoupdate
12#
13# See https://github.com/pre-commit/pre-commit
14
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040015repos:
Henry Schreinerfd61f502020-09-16 17:13:41 -040016# Standard hooks
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040017- repo: https://github.com/pre-commit/pre-commit-hooks
Henry Schreinerfd61f502020-09-16 17:13:41 -040018 rev: v3.2.0
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040019 hooks:
20 - id: check-added-large-files
21 - id: check-case-conflict
22 - id: check-merge-conflict
23 - id: check-symlinks
24 - id: check-yaml
25 - id: debug-statements
26 - id: end-of-file-fixer
27 - id: mixed-line-ending
28 - id: requirements-txt-fixer
29 - id: trailing-whitespace
30 - id: fix-encoding-pragma
31
Henry Schreinerfd61f502020-09-16 17:13:41 -040032# Black, the code formatter, natively supports pre-commit
33- repo: https://github.com/psf/black
34 rev: 20.8b1
35 hooks:
36 - id: black
37 # Not all Python files are Blacked, yet
38 files: ^(setup.py|pybind11|tests/extra)
39
40# Changes tabs to spaces
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040041- repo: https://github.com/Lucas-C/pre-commit-hooks
Henry Schreiner5c936d42020-07-21 09:34:20 -040042 rev: v1.1.9
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040043 hooks:
44 - id: remove-tabs
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040045
Henry Schreinerfd61f502020-09-16 17:13:41 -040046# Flake8 also supports pre-commit natively (same author)
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040047- repo: https://gitlab.com/pycqa/flake8
Henry Schreiner5c936d42020-07-21 09:34:20 -040048 rev: 3.8.3
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040049 hooks:
50 - id: flake8
Henry Schreiner8b0ccf72020-07-20 15:07:22 -040051 additional_dependencies: [flake8-bugbear, pep8-naming]
Henry Schreinerd8c7ee02020-07-20 13:35:21 -040052 exclude: ^(docs/.*|tools/.*)$
Henry Schreiner8b0ccf72020-07-20 15:07:22 -040053
Henry Schreinerfd61f502020-09-16 17:13:41 -040054# CMake formatting
Henry Schreinere2a96892020-07-29 16:42:07 -040055- repo: https://github.com/cheshirekow/cmake-format-precommit
Henry Schreinered6de122020-08-01 23:47:47 -040056 rev: v0.6.11
Henry Schreinere2a96892020-07-29 16:42:07 -040057 hooks:
58 - id: cmake-format
59 additional_dependencies: [pyyaml]
Henry Schreinered6de122020-08-01 23:47:47 -040060 types: [file]
61 files: (\.cmake|CMakeLists.txt)(.in)?$
Henry Schreinere2a96892020-07-29 16:42:07 -040062
Henry Schreinerfd61f502020-09-16 17:13:41 -040063# Checks the manifest for missing files (native support)
64- repo: https://github.com/mgedmin/check-manifest
65 rev: "0.42"
66 hooks:
67 - id: check-manifest
68 # This is a slow hook, so only run this if --hook-stage manual is passed
69 stages: [manual]
70 additional_dependencies: [cmake, ninja]
71
72# The original pybind11 checks for a few C++ style items
Henry Schreiner8b0ccf72020-07-20 15:07:22 -040073- repo: local
74 hooks:
Henry Schreiner37f845a2020-09-08 09:26:50 -040075 - id: disallow-caps
76 name: Disallow improper capitalization
77 language: pygrep
78 entry: PyBind|Numpy|Cmake
79 exclude: .pre-commit-config.yaml
80
81- repo: local
82 hooks:
Henry Schreiner8b0ccf72020-07-20 15:07:22 -040083 - id: check-style
84 name: Classic check-style
85 language: system
86 types:
87 - c++
88 entry: ./tools/check-style.sh