.pre-commit-config.yaml 4.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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

15
16
17
# third-party content
exclude: ^tools/JoinPaths.cmake$

18
repos:
19
# Standard hooks
20
- repo: https://github.com/pre-commit/pre-commit-hooks
21
  rev: "v4.3.0"
22
23
24
  hooks:
  - id: check-added-large-files
  - id: check-case-conflict
25
  - id: check-docstring-first
26
27
  - id: check-merge-conflict
  - id: check-symlinks
28
  - id: check-toml
29
30
31
32
33
34
35
  - id: check-yaml
  - id: debug-statements
  - id: end-of-file-fixer
  - id: mixed-line-ending
  - id: requirements-txt-fixer
  - id: trailing-whitespace

36
# Upgrade old Python syntax
37
- repo: https://github.com/asottile/pyupgrade
38
  rev: "v2.38.2"
39
40
  hooks:
  - id: pyupgrade
41
    args: [--py36-plus]
42

43
# Nicely sort includes
44
- repo: https://github.com/PyCQA/isort
45
  rev: "5.10.1"
46
47
48
  hooks:
  - id: isort

49
50
# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
51
  rev: "22.8.0" # Keep in sync with blacken-docs
52
53
  hooks:
  - id: black
54

55
# Also code format the docs
56
- repo: https://github.com/asottile/blacken-docs
57
  rev: "v1.12.1"
58
59
60
  hooks:
  - id: blacken-docs
    additional_dependencies:
61
    - black==22.8.0 # keep in sync with black hook
62
63

# Changes tabs to spaces
64
- repo: https://github.com/Lucas-C/pre-commit-hooks
65
  rev: "v1.3.1"
66
67
68
  hooks:
  - id: remove-tabs

69
- repo: https://github.com/sirosen/texthooks
70
  rev: "0.4.0"
71
72
73
74
  hooks:
  - id: fix-ligatures
  - id: fix-smartquotes

75
76
# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
77
  rev: "v2.1.1"
78
79
  hooks:
  - id: pycln
Henry Schreiner's avatar
Henry Schreiner committed
80
    stages: [manual]
81

82
# Checking for common mistakes
83
- repo: https://github.com/pre-commit/pygrep-hooks
84
  rev: "v1.9.0"
85
86
87
88
  hooks:
  - id: python-check-blanket-noqa
  - id: python-check-blanket-type-ignore
  - id: python-no-log-warn
89
  - id: python-use-type-annotations
90
91
92
93
  - id: rst-backticks
  - id: rst-directive-colons
  - id: rst-inline-touching-normal

Henry Schreiner's avatar
Henry Schreiner committed
94
95
# Automatically remove noqa that are not used
- repo: https://github.com/asottile/yesqa
96
  rev: "v1.4.0"
Henry Schreiner's avatar
Henry Schreiner committed
97
98
99
100
101
102
  hooks:
  - id: yesqa
    additional_dependencies: &flake8_dependencies
      - flake8-bugbear
      - pep8-naming

103
# Flake8 also supports pre-commit natively (same author)
104
- repo: https://github.com/PyCQA/flake8
105
  rev: "5.0.4"
106
107
108
  hooks:
  - id: flake8
    exclude: ^(docs/.*|tools/.*)$
Henry Schreiner's avatar
Henry Schreiner committed
109
    additional_dependencies: *flake8_dependencies
110

Henry Schreiner's avatar
Henry Schreiner committed
111
112
# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
113
  rev: "v2.15.3"
114
  hooks:
Henry Schreiner's avatar
Henry Schreiner committed
115
116
  - id: pylint
    files: ^pybind11
117

118
# CMake formatting
119
- repo: https://github.com/cheshirekow/cmake-format-precommit
120
  rev: "v0.6.13"
121
122
123
  hooks:
  - id: cmake-format
    additional_dependencies: [pyyaml]
Henry Schreiner's avatar
Henry Schreiner committed
124
125
    types: [file]
    files: (\.cmake|CMakeLists.txt)(.in)?$
126

127
128
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
129
  rev: "v0.981"
130
131
  hooks:
  - id: mypy
Henry Schreiner's avatar
Henry Schreiner committed
132
    args: []
133
134
    exclude: ^(tests|docs)/
    additional_dependencies: [nox, rich]
135

136
137
# Checks the manifest for missing files (native support)
- repo: https://github.com/mgedmin/check-manifest
138
  rev: "0.48"
139
140
141
142
143
144
  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]

145
# Check for spelling
146
147
# Use tools/codespell_ignore_lines_from_errors.py
# to rebuild .codespell-ignore-lines
148
- repo: https://github.com/codespell-project/codespell
149
  rev: "v2.2.1"
150
151
  hooks:
  - id: codespell
152
    exclude: ".supp$"
153
    args: ["-x", ".codespell-ignore-lines"]
154

155
# Check for common shell mistakes
156
- repo: https://github.com/shellcheck-py/shellcheck-py
157
  rev: "v0.8.0.4"
158
159
  hooks:
  - id: shellcheck
160

161
# Disallow some common capitalization mistakes
162
163
164
165
166
- repo: local
  hooks:
  - id: disallow-caps
    name: Disallow improper capitalization
    language: pygrep
167
    entry: PyBind|Numpy|Cmake|CCache|PyTest
168
    exclude: ^\.pre-commit-config.yaml$
169

170
# Clang format the codebase automatically
171
- repo: https://github.com/pre-commit/mirrors-clang-format
172
  rev: "v14.0.6"
173
  hooks:
174
  - id: clang-format
175
    types_or: [c++, c, cuda]