"vscode:/vscode.git/clone" did not exist on "3351eba0aa33668f8f4cf5d24eb5f68fce17e034"
.pre-commit-config.yaml 4.23 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
18
19
20

ci:
  autoupdate_commit_msg: "chore(deps): update pre-commit hooks"
  autofix_commit_msg: "style: pre-commit fixes"
  autoupdate_schedule: monthly

21
22
23
# third-party content
exclude: ^tools/JoinPaths.cmake$

24
repos:
25
# Standard hooks
26
- repo: https://github.com/pre-commit/pre-commit-hooks
27
  rev: "v4.4.0"
28
29
30
  hooks:
  - id: check-added-large-files
  - id: check-case-conflict
31
  - id: check-docstring-first
32
33
  - id: check-merge-conflict
  - id: check-symlinks
34
  - id: check-toml
35
36
37
38
39
40
41
  - id: check-yaml
  - id: debug-statements
  - id: end-of-file-fixer
  - id: mixed-line-ending
  - id: requirements-txt-fixer
  - id: trailing-whitespace

42
# Upgrade old Python syntax
43
- repo: https://github.com/asottile/pyupgrade
44
  rev: "v3.3.0"
45
46
  hooks:
  - id: pyupgrade
47
    args: [--py36-plus]
48

49
# Nicely sort includes
50
- repo: https://github.com/PyCQA/isort
51
  rev: "5.10.1"
52
53
54
  hooks:
  - id: isort

55
56
# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
57
  rev: "22.10.0" # Keep in sync with blacken-docs
58
59
  hooks:
  - id: black
60

61
# Also code format the docs
62
- repo: https://github.com/asottile/blacken-docs
63
  rev: "v1.12.1"
64
65
66
  hooks:
  - id: blacken-docs
    additional_dependencies:
67
    - black==22.10.0 # keep in sync with black hook
68
69

# Changes tabs to spaces
70
- repo: https://github.com/Lucas-C/pre-commit-hooks
71
  rev: "v1.3.1"
72
73
74
  hooks:
  - id: remove-tabs

75
- repo: https://github.com/sirosen/texthooks
76
  rev: "0.4.0"
77
78
79
80
  hooks:
  - id: fix-ligatures
  - id: fix-smartquotes

81
82
# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
83
  rev: "v2.1.2"
84
85
  hooks:
  - id: pycln
Henry Schreiner's avatar
Henry Schreiner committed
86
    stages: [manual]
87

88
# Checking for common mistakes
89
- repo: https://github.com/pre-commit/pygrep-hooks
90
  rev: "v1.9.0"
91
92
93
94
  hooks:
  - id: python-check-blanket-noqa
  - id: python-check-blanket-type-ignore
  - id: python-no-log-warn
95
  - id: python-use-type-annotations
96
97
98
99
  - id: rst-backticks
  - id: rst-directive-colons
  - id: rst-inline-touching-normal

Henry Schreiner's avatar
Henry Schreiner committed
100
101
# Automatically remove noqa that are not used
- repo: https://github.com/asottile/yesqa
102
  rev: "v1.4.0"
Henry Schreiner's avatar
Henry Schreiner committed
103
104
105
106
107
108
  hooks:
  - id: yesqa
    additional_dependencies: &flake8_dependencies
      - flake8-bugbear
      - pep8-naming

109
# Flake8 also supports pre-commit natively (same author)
110
- repo: https://github.com/PyCQA/flake8
111
  rev: "6.0.0"
112
113
114
  hooks:
  - id: flake8
    exclude: ^(docs/.*|tools/.*)$
Henry Schreiner's avatar
Henry Schreiner committed
115
    additional_dependencies: *flake8_dependencies
116

Henry Schreiner's avatar
Henry Schreiner committed
117
118
# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
119
  rev: "v2.15.8"
120
  hooks:
Henry Schreiner's avatar
Henry Schreiner committed
121
122
  - id: pylint
    files: ^pybind11
123

124
# CMake formatting
125
- repo: https://github.com/cheshirekow/cmake-format-precommit
126
  rev: "v0.6.13"
127
128
129
  hooks:
  - id: cmake-format
    additional_dependencies: [pyyaml]
Henry Schreiner's avatar
Henry Schreiner committed
130
131
    types: [file]
    files: (\.cmake|CMakeLists.txt)(.in)?$
132

133
134
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
135
  rev: "v0.991"
136
137
  hooks:
  - id: mypy
Henry Schreiner's avatar
Henry Schreiner committed
138
    args: []
139
140
    exclude: ^(tests|docs)/
    additional_dependencies: [nox, rich]
141

142
143
# Checks the manifest for missing files (native support)
- repo: https://github.com/mgedmin/check-manifest
144
  rev: "0.49"
145
146
147
148
149
150
  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]

151
# Check for spelling
152
153
# Use tools/codespell_ignore_lines_from_errors.py
# to rebuild .codespell-ignore-lines
154
- repo: https://github.com/codespell-project/codespell
155
  rev: "v2.2.2"
156
157
  hooks:
  - id: codespell
158
    exclude: ".supp$"
159
    args: ["-x", ".codespell-ignore-lines"]
160

161
# Check for common shell mistakes
162
- repo: https://github.com/shellcheck-py/shellcheck-py
163
  rev: "v0.8.0.4"
164
165
  hooks:
  - id: shellcheck
166

167
# Disallow some common capitalization mistakes
168
169
170
171
172
- repo: local
  hooks:
  - id: disallow-caps
    name: Disallow improper capitalization
    language: pygrep
173
    entry: PyBind|Numpy|Cmake|CCache|PyTest
174
    exclude: ^\.pre-commit-config.yaml$
175

176
# Clang format the codebase automatically
177
- repo: https://github.com/pre-commit/mirrors-clang-format
178
  rev: "v15.0.4"
179
  hooks:
180
  - id: clang-format
181
    types_or: [c++, c, cuda]