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 | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 18 | rev: v3.2.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 |
| 37 | # Not all Python files are Blacked, yet |
| 38 | files: ^(setup.py|pybind11|tests/extra) |
| 39 | |
| 40 | # Changes tabs to spaces |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 41 | - repo: https://github.com/Lucas-C/pre-commit-hooks |
Henry Schreiner | 5c936d4 | 2020-07-21 09:34:20 -0400 | [diff] [blame] | 42 | rev: v1.1.9 |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 43 | hooks: |
| 44 | - id: remove-tabs |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 45 | |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 46 | # Flake8 also supports pre-commit natively (same author) |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 47 | - repo: https://gitlab.com/pycqa/flake8 |
Henry Schreiner | 5c936d4 | 2020-07-21 09:34:20 -0400 | [diff] [blame] | 48 | rev: 3.8.3 |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 49 | hooks: |
| 50 | - id: flake8 |
Henry Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 51 | additional_dependencies: [flake8-bugbear, pep8-naming] |
Henry Schreiner | d8c7ee0 | 2020-07-20 13:35:21 -0400 | [diff] [blame] | 52 | exclude: ^(docs/.*|tools/.*)$ |
Henry Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 53 | |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 54 | # CMake formatting |
Henry Schreiner | e2a9689 | 2020-07-29 16:42:07 -0400 | [diff] [blame] | 55 | - repo: https://github.com/cheshirekow/cmake-format-precommit |
Henry Schreiner | ed6de12 | 2020-08-01 23:47:47 -0400 | [diff] [blame] | 56 | rev: v0.6.11 |
Henry Schreiner | e2a9689 | 2020-07-29 16:42:07 -0400 | [diff] [blame] | 57 | hooks: |
| 58 | - id: cmake-format |
| 59 | additional_dependencies: [pyyaml] |
Henry Schreiner | ed6de12 | 2020-08-01 23:47:47 -0400 | [diff] [blame] | 60 | types: [file] |
| 61 | files: (\.cmake|CMakeLists.txt)(.in)?$ |
Henry Schreiner | e2a9689 | 2020-07-29 16:42:07 -0400 | [diff] [blame] | 62 | |
Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 63 | # 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 Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 73 | - repo: local |
| 74 | hooks: |
Henry Schreiner | 37f845a | 2020-09-08 09:26:50 -0400 | [diff] [blame] | 75 | - 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 Schreiner | 8b0ccf7 | 2020-07-20 15:07:22 -0400 | [diff] [blame] | 83 | - id: check-style |
| 84 | name: Classic check-style |
| 85 | language: system |
| 86 | types: |
| 87 | - c++ |
| 88 | entry: ./tools/check-style.sh |