-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
420 lines (370 loc) · 13.7 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
default_language_version:
python: python3.12
minimum_pre_commit_version: 3.5.0
default_install_hook_types: [commit-msg,
post-checkout,
post-commit,
post-merge,
post-rewrite,
pre-commit,
pre-merge-commit,
pre-push,
pre-rebase,
prepare-commit-msg
]
files: ''
exclude: |
(?x)^(
venv/.*|
.git/.*|
book/_build/.*
)$
fail_fast: true # false #
default_stages: [pre-commit, pre-merge-commit, pre-push]
repos:
- repo: local
hooks:
#======================================================================================================================
# Git hooks
#======================================================================================================================
- id: forbid-new-submodules
name: "Prevent addition of new git submodules (forbid-new-submodules)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: forbid-new-submodules
types: [file]
require_serial: true
- id: check-merge-conflict
name: "Check for files that contain merge conflict strings (check-merge-conflict)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-merge-conflict
types: [file]
require_serial: true
- id: check-added-large-files
name: "Prevent giant files from being committed (check-added-large-files)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-added-large-files
args: [--maxkb=10240,
--enforce-all,
]
types: [file]
require_serial: true
- id: check-case-conflict
name: "Check for files with names that would conflict on a case-insensitive filesystem (check-case-conflict)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-case-conflict
types: [file]
require_serial: true
#======================================================================================================================
# Common files hooks
#======================================================================================================================
- id: trailing-whitespace
name: "Trims trailing whitespace (trailing-whitespace)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: trailing-whitespace-fixer
types: [text]
require_serial: true
- id: mixed-line-ending
name: "Replaces or checks mixed line ending (mixed-line-ending)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: mixed-line-ending
args: [--fix=lf]
types: [text]
require_serial: true
- id: end-of-file-fixer
name: "Makes sure files end in a newline and only a newline (end-of-file-fixer)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: end-of-file-fixer
types_or: [markdown, pyi, python, toml]
require_serial: true
- id: fix-byte-order-marker
name: "Removes UTF-8 byte order marker (fix-byte-order-marker)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: fix-byte-order-marker
types: [text]
require_serial: true
# False positives raised by check-executables-have-shebangs
# https://github.com/pre-commit/pre-commit-hooks/issues/528
# - id: check-executables-have-shebangs
# name: "Checks that non-binary executables have a proper shebang (check-executables-have-shebangs)"
# description: "https://github.com/pre-commit/pre-commit-hooks"
# language: system
# entry: check-executables-have-shebangs
# types_or: [bash, python]
# require_serial: true
- id: check-symlinks
name: "Checks for symlinks which do not point to anything (check-symlinks)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-symlinks
types_or: [text]
require_serial: true
- id: check-vcs-permalinks
name: "Ensures that links to vcs websites are permalinks (check-vcs-permalinks)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-vcs-permalinks
types_or: [text]
require_serial: true
- id: destroyed-symlinks
name: "Detects symlinks which are changed to regular files with a content of a path (destroyed-symlinks)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: destroyed-symlinks
types_or: [text]
require_serial: true
- id: detect-private-key
name: "Checks for the existence of private keys (detect-private-key)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: detect-private-key
types_or: [text]
require_serial: true
#======================================================================================================================
# Type files hooks
#======================================================================================================================
- id: check-ast
name: "Simply check whether files parse as valid python (check-ast)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-ast
types_or: [pyi, python]
require_serial: true
- id: pretty-format-json
name: "Checks that all your JSON files are pretty (pretty-format-json)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: pretty-format-json
args: [--autofix,
--indent=4,
--no-ensure-ascii,
--no-sort-keys,
]
types_or: [json, jupyter]
require_serial: true
- id: check-json
name: "Attempts to load all json files to verify syntax (check-json)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-json
types_or: [json, jupyter]
require_serial: true
- id: check-toml
name: "Attempts to load all TOML files to verify syntax (check-toml)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-toml
types: [toml]
require_serial: true
- id: check-xml
name: "Attempts to load all xml files to verify syntax (check-xml)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-xml
types_or: [html, xml, xhtml]
require_serial: true
- id: check-yaml
name: "Attempts to load all yaml files to verify syntax (check-yaml)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-yaml
args: [--allow-multiple-documents]
types: [yaml]
require_serial: true
- id: requirements-txt-fixer
name: "Sorts entries in requirements.txt and constraints.txt (requirements-txt-fixer)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: requirements-txt-fixer
files: .*(requirements).*(.txt)$
require_serial: true
verbose: true
#======================================================================================================================
# Python hooks
#======================================================================================================================
- id: fix-encoding-pragma
name: "Remove # -*- coding: utf-8 -*- to the top of python files (fix-encoding-pragma)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: fix-encoding-pragma
args: [--remove]
types_or: [pyi, python]
require_serial: true
- id: check-docstring-first
name: "Checks for a common error of placing code before the docstring (check-docstring-first)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: check-docstring-first
types_or: [pyi, python]
require_serial: true
- id: debug-statements
name: "Check for debugger imports and py37+ breakpoint() calls in python source (debug-statements)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: debug-statement-hook
types_or: [pyi, python]
require_serial: true
- id: pyupgrade
name: "Automatically upgrade syntax for newer versions (pyupgrade)"
description: "https://github.com/asottile/pyupgrade"
language: system
entry: python -m pyupgrade
args: [--py312-plus]
types_or: [pyi, python]
require_serial: true
- id: pyupgrade-nbqa
name: "Automatically upgrade syntax for newer versions (pyupgrade + nbqa)"
description: "https://github.com/asottile/pyupgrade
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa pyupgrade
args: [--py312-plus]
types_or: [jupyter, markdown]
require_serial: true
# - id: check-builtin-literals
# name: "Require literal syntax when initializing empty or zero Python builtin types (check-builtin-literals)"
# description: "https://github.com/pre-commit/pre-commit-hooks"
# language: system
# entry: check-builtin-literals
# types_or: [jupyter, markdown, pyi, python ]
# require_serial: true
- id: isort
name: "Import sorting (isort)"
description: "https://github.com/pycqa/isort"
language: system
entry: python -m isort
args: [--settings-file=pyproject.toml,
--float-to-top,
]
types_or: [pyi, python]
require_serial: true
- id: isort-nbqa
name: "Import sorting (isort + nbqa)"
description: "https://github.com/pycqa/isort
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa isort
args: [--settings-file=pyproject.toml]
types_or: [jupyter, markdown]
require_serial: true
- id: black
name: "Python code formatter (black)"
description: "https://github.com/psf/black"
language: system
entry: python -m black
args: [--config=pyproject.toml]
types_or: [pyi, python]
require_serial: true
- id: black-nbqa
name: "Python code formatter (black + nbqa)"
description: "https://github.com/psf/black
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa black
args: [--config=pyproject.toml]
types_or: [jupyter, markdown]
require_serial: true
- id: mypy
name: "Static type checking (mypy)"
description: "https://github.com/python/mypy"
language: system
entry: python -m mypy
args: [--config-file=pyproject.toml]
types_or: [pyi, python]
require_serial: true
- id: mypy-nbqa
name: "Static type checking (mypy + nbqa)"
description: "https://github.com/python/mypy
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa mypy
args: [--config-file=pyproject.toml]
types_or: [jupyter, markdown]
require_serial: true
- id: bandit
name: "Security code analysis (bandit)"
description: "https://github.com/PyCQA/bandit"
language: system
entry: python -m bandit
args: [--configfile=pyproject.toml]
types_or: [pyi, python]
require_serial: true
- id: bandit-nbqa
name: "Security code analysis (bandit + nbqa)"
description: "https://github.com/PyCQA/bandit
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa bandit
args: [--configfile=pyproject.toml]
types_or: [jupyter, markdown]
require_serial: true
- id: pylint
name: "Static code analysis (pylint)"
description: "https://github.com/pylint-dev/pylint"
language: system
entry: python -m pylint
args: [--rcfile=pyproject.toml]
types_or: [pyi, python]
require_serial: true
- id: pylint-nbqa
name: "Static code analysis (pylint + nbqa)"
description: "https://github.com/pylint-dev/pylint
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa pylint
args: [--rcfile=pyproject.toml,
--disable=C0103, # Skip the hyphen in the file name (invalid-name)
--disable=C0111, # Missing module docstring (missing-module-docstring)
--disable=C0413, # Import should be placed at the top of the module (wrong-import-position)
]
types_or: [jupyter, markdown]
require_serial: true
- id: doctest
name: "Test interactive Python examples (doctest)"
description: "https://docs.python.org/3/library/doctest.html"
language: system
entry: python -m doctest
#args: [--verbose]
types: [python]
require_serial: true
- id: doctest-nbqa
name: "Test interactive Python examples (doctest + nbqa)"
description: "https://docs.python.org/3/library/doctest.html
https://github.com/nbQA-dev/nbQA"
language: system
entry: python -m nbqa doctest
#args: [--verbose]
types_or: [jupyter, markdown, tex]
require_serial: true
- id: name-tests-test
name: "Verifies that test files are named correctly (name-tests-test)"
description: "https://github.com/pre-commit/pre-commit-hooks"
language: system
entry: name-tests-test
args: [--pytest]
files: ^tests/
types: [python]
require_serial: true
- id: pytest
name: "Testing the code (pytest)"
description: "https://github.com/pytest-dev/pytest/"
language: system
entry: python -m pytest
args: [--tb=line,
--cache-clear,
--ignore=./tests/__init__.py,
--doctest-modules,
--verbose,
]
files: ^(tests\/).*(_test.py)$
types: [python]
require_serial: true
always_run: true
verbose: true