|
| 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 | + |
| 15 | +repos: |
| 16 | +# Standard hooks |
| 17 | +- repo: https://github.com/pre-commit/pre-commit-hooks |
| 18 | + rev: "v4.4.0" |
| 19 | + hooks: |
| 20 | + - id: check-added-large-files |
| 21 | + - id: check-case-conflict |
| 22 | + - id: check-docstring-first |
| 23 | + - id: check-merge-conflict |
| 24 | + - id: check-symlinks |
| 25 | + - id: check-toml |
| 26 | + - id: check-yaml |
| 27 | + - id: debug-statements |
| 28 | + - id: end-of-file-fixer |
| 29 | + - id: mixed-line-ending |
| 30 | + - id: requirements-txt-fixer |
| 31 | + - id: trailing-whitespace |
| 32 | + |
| 33 | +# Black, the code formatter, natively supports pre-commit |
| 34 | +- repo: https://github.com/psf/black |
| 35 | + rev: "23.3.0" # Keep in sync with blacken-docs |
| 36 | + hooks: |
| 37 | + - id: black |
| 38 | + |
| 39 | +# Also code format the docs |
| 40 | +- repo: https://github.com/asottile/blacken-docs |
| 41 | + rev: "1.13.0" |
| 42 | + hooks: |
| 43 | + - id: blacken-docs |
| 44 | + additional_dependencies: |
| 45 | + - black==22.8.0 # keep in sync with black hook |
| 46 | + |
| 47 | +# Changes tabs to spaces |
| 48 | +- repo: https://github.com/Lucas-C/pre-commit-hooks |
| 49 | + rev: "v1.5.1" |
| 50 | + hooks: |
| 51 | + - id: remove-tabs |
| 52 | + |
| 53 | +- repo: https://github.com/sirosen/texthooks |
| 54 | + rev: "0.5.0" |
| 55 | + hooks: |
| 56 | + - id: fix-ligatures |
| 57 | + - id: fix-smartquotes |
| 58 | + |
| 59 | + |
| 60 | +# Checking for common mistakes |
| 61 | +- repo: https://github.com/pre-commit/pygrep-hooks |
| 62 | + rev: "v1.10.0" |
| 63 | + hooks: |
| 64 | + - id: rst-backticks |
| 65 | + - id: rst-directive-colons |
| 66 | + - id: rst-inline-touching-normal |
| 67 | + |
| 68 | + |
| 69 | +# PyLint has native support - not always usable, but works for us |
| 70 | +- repo: https://github.com/PyCQA/pylint |
| 71 | + rev: "v3.0.0a6" |
| 72 | + hooks: |
| 73 | + - id: pylint |
| 74 | + files: ^pybind11 |
| 75 | + |
| 76 | +# CMake formatting |
| 77 | +- repo: https://github.com/cheshirekow/cmake-format-precommit |
| 78 | + rev: "v0.6.13" |
| 79 | + hooks: |
| 80 | + - id: cmake-format |
| 81 | + additional_dependencies: [pyyaml] |
| 82 | + types: [file] |
| 83 | + files: (\.cmake|CMakeLists.txt)(.in)?$ |
| 84 | + |
| 85 | +# Check static types with mypy |
| 86 | +#- repo: https://github.com/pre-commit/mirrors-mypy |
| 87 | +# rev: "v0.971" |
| 88 | +# hooks: |
| 89 | +# - id: mypy |
| 90 | +# args: [] |
| 91 | +# exclude: ^(tests|docs)/ |
| 92 | +# additional_dependencies: [nox, rich] |
| 93 | + |
| 94 | +# Checks the manifest for missing files (native support) |
| 95 | +- repo: https://github.com/mgedmin/check-manifest |
| 96 | + rev: "0.49" |
| 97 | + hooks: |
| 98 | + - id: check-manifest |
| 99 | + # This is a slow hook, so only run this if --hook-stage manual is passed |
| 100 | + stages: [manual] |
| 101 | + additional_dependencies: [cmake, ninja] |
| 102 | + |
| 103 | +- repo: https://github.com/charliermarsh/ruff-pre-commit |
| 104 | + rev: v0.0.261 |
| 105 | + hooks: |
| 106 | + - id: ruff |
| 107 | + args: ["--fix", "--show-fixes"] |
| 108 | + |
| 109 | +# Check for spelling |
| 110 | +- repo: https://github.com/codespell-project/codespell |
| 111 | + rev: "v2.2.4" |
| 112 | + hooks: |
| 113 | + - id: codespell |
| 114 | + exclude: ".*/test_.*.py" |
| 115 | + args: ["-L", "aline,alo,ore"] |
| 116 | + |
| 117 | +# Check for common shell mistakes |
| 118 | +- repo: https://github.com/shellcheck-py/shellcheck-py |
| 119 | + rev: "v0.9.0.2" |
| 120 | + hooks: |
| 121 | + - id: shellcheck |
| 122 | + |
| 123 | +# Disallow some common capitalization mistakes |
| 124 | +- repo: local |
| 125 | + hooks: |
| 126 | + - id: disallow-caps |
| 127 | + name: Disallow improper capitalization |
| 128 | + language: pygrep |
| 129 | + entry: PyBind|Numpy|Cmake|CCache|PyTest |
| 130 | + exclude: ^\.pre-commit-config.yaml$ |
| 131 | + |
0 commit comments