Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 1 | # 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 Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 15 | repos: |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 16 | # Standard hooks |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 17 | - repo: https://github.com/pre-commit/pre-commit-hooks |
Henry Schreiner | 8e5d3d2 | 2021-01-25 16:09:36 -0500 | [diff] [blame] | 18 | rev: v3.4.0 |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 19 | 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 Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 32 | # Black, the code formatter, natively supports pre-commit |
| 33 | - repo: https://github.com/psf/black |
| 34 | rev: 20.8b1 |
| 35 | hooks: |
| 36 | - id: black |
Henry Schreiner | 645d838 | 2020-10-14 14:08:41 -0400 | [diff] [blame] | 37 | # By default, this ignores pyi files, though black supports them |
| 38 | types: [text] |
Henry Schreiner | c50f90e | 2020-10-16 16:38:13 -0400 | [diff] [blame] | 39 | files: \.pyi?$ |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 40 | |
| 41 | # Changes tabs to spaces |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 42 | - repo: https://github.com/Lucas-C/pre-commit-hooks |
Henry Schreiner | 5c936d4 | 2020-07-21 09:34:20 -0400 | [diff] [blame] | 43 | rev: v1.1.9 |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 44 | hooks: |
| 45 | - id: remove-tabs |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 46 | |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 47 | # Flake8 also supports pre-commit natively (same author) |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 48 | - repo: https://gitlab.com/pycqa/flake8 |
Henry Schreiner | 8e5d3d2 | 2021-01-25 16:09:36 -0500 | [diff] [blame] | 49 | rev: 3.8.4 |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 50 | hooks: |
| 51 | - id: flake8 |
Henry Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 52 | additional_dependencies: [flake8-bugbear, pep8-naming] |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 53 | exclude: ^(docs/.*|tools/.*)$ |
Henry Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 54 | |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 55 | # CMake formatting |
Henry Schreiner | e2a9689 | 2020-07-29 16:42:07 -0400 | [diff] [blame] | 56 | - repo: https://github.com/cheshirekow/cmake-format-precommit |
Henry Schreiner | 82dbc5b | 2020-09-30 15:48:08 -0400 | [diff] [blame] | 57 | rev: v0.6.13 |
Henry Schreiner | e2a9689 | 2020-07-29 16:42:07 -0400 | [diff] [blame] | 58 | hooks: |
| 59 | - id: cmake-format |
| 60 | additional_dependencies: [pyyaml] |
Henry Schreiner | ed6de12 | 2020-08-01 23:47:47 -0400 | [diff] [blame] | 61 | types: [file] |
| 62 | files: (\.cmake|CMakeLists.txt)(.in)?$ |
Henry Schreiner | e2a9689 | 2020-07-29 16:42:07 -0400 | [diff] [blame] | 63 | |
Henry Schreiner | 645d838 | 2020-10-14 14:08:41 -0400 | [diff] [blame] | 64 | # Check static types with mypy |
| 65 | - repo: https://github.com/pre-commit/mirrors-mypy |
Henry Schreiner | 8e5d3d2 | 2021-01-25 16:09:36 -0500 | [diff] [blame] | 66 | rev: v0.800 |
Henry Schreiner | 645d838 | 2020-10-14 14:08:41 -0400 | [diff] [blame] | 67 | hooks: |
| 68 | - id: mypy |
| 69 | # The default Python type ignores .pyi files, so let's rerun if detected |
| 70 | types: [text] |
| 71 | files: ^pybind11.*\.pyi?$ |
| 72 | # Running per-file misbehaves a bit, so just run on all files, it's fast |
| 73 | pass_filenames: false |
| 74 | |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 75 | # Checks the manifest for missing files (native support) |
| 76 | - repo: https://github.com/mgedmin/check-manifest |
Henry Schreiner | 8e5d3d2 | 2021-01-25 16:09:36 -0500 | [diff] [blame] | 77 | rev: "0.46" |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 78 | hooks: |
| 79 | - id: check-manifest |
| 80 | # This is a slow hook, so only run this if --hook-stage manual is passed |
| 81 | stages: [manual] |
| 82 | additional_dependencies: [cmake, ninja] |
| 83 | |
| 84 | # The original pybind11 checks for a few C++ style items |
Henry Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 85 | - repo: local |
| 86 | hooks: |
Henry Schreiner | 37f845a | 2020-09-08 09:26:50 -0400 | [diff] [blame] | 87 | - id: disallow-caps |
| 88 | name: Disallow improper capitalization |
| 89 | language: pygrep |
Henry Schreiner | ebd5c5b | 2020-11-11 11:45:28 -0500 | [diff] [blame] | 90 | entry: PyBind|Numpy|Cmake|CCache |
Henry Schreiner | 37f845a | 2020-09-08 09:26:50 -0400 | [diff] [blame] | 91 | exclude: .pre-commit-config.yaml |
| 92 | |
| 93 | - repo: local |
| 94 | hooks: |
Henry Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 95 | - id: check-style |
| 96 | name: Classic check-style |
| 97 | language: system |
| 98 | types: |
| 99 | - c++ |
| 100 | entry: ./tools/check-style.sh |