-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
417 lines (390 loc) · 13.3 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
# See https://pre-commit.com for more information
repos:
# poetry - commented out due to long run times
# - repo: https://github.com/python-poetry/poetry
# rev: '1.8.2'
# hooks:
# - id: poetry-check
# - id: poetry-lock
# isort
- repo: https://github.com/pycqa/isort
rev: '5.13.2'
hooks:
- id: isort
# pyupgrade
- repo: https://github.com/asottile/pyupgrade
rev: 'v3.15.1'
hooks:
- id: pyupgrade
# black
- repo: https://github.com/psf/black
rev: '24.3.0'
hooks:
- id: black-jupyter
- repo: https://github.com/adamchainz/blacken-docs
rev: '1.16.0'
hooks:
- id: blacken-docs
args: ['--line-length=100']
additional_dependencies: ['black==24.3.0']
# flake8
- repo: https://github.com/pycqa/flake8
rev: '7.0.0'
hooks:
- id: flake8
additional_dependencies: [
flake8-absolute-import,
flake8-all-not-strings,
flake8-annotations,
flake8-assertive,
flake8-async,
flake8-boolean-trap,
flake8-broken-line,
flake8-bugbear,
flake8-builtins,
flake8-clean-block,
flake8-coding,
flake8-comments,
flake8-comprehensions,
flake8-datetimez,
flake8-dunder-all,
flake8-dunder-class-obj,
flake8-eradicate,
flake8-escaping-style,
flake8-functions-names,
flake8-future-annotations,
flake8-get-chaining,
flake8-github-annotations,
flake8-import-conventions,
flake8-inflammatory-jargon,
flake8-keyword-params,
flake8-literal,
flake8-logging,
flake8-loopy,
flake8-mutable,
flake8-no-debug-vars,
flake8-no-implicit-concat,
flake8-noqa,
flake8-pep3101,
flake8-pep585,
flake8-picky-parentheses,
flake8-pie,
flake8-printf-formatting,
flake8-pyprojecttoml,
flake8-pytest-style,
flake8-return,
flake8-secure-coding-standard,
flake8-simplify,
flake8-string-format,
flake8-type-checking,
flake8-typing-as-t,
flake8-unused-arguments,
flake8-use-fstring,
flake8-use-pathlib,
dlint,
pandas-vet,
pydoclint,
tryceratops
]
# mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.8.0'
hooks:
- id: mypy
# pylint
# https://pylint.readthedocs.io/en/latest/user_guide/installation/pre-commit-integration.html#pre-commit-integration
- repo: local
hooks:
- id: pylint
name: pylint
entry: poetry run pylint -sn
language: system
types: [python]
# bandit
- repo: https://github.com/PyCQA/bandit
rev: '1.7.7'
hooks:
- id: bandit
args: ['-q']
# vulture
- repo: https://github.com/jendrikseipp/vulture
rev: 'v2.11'
hooks:
- id: vulture
# deptry - only works when run within poetry env, but can't ensure from within pre-commit
# - repo: https://github.com/fpgmaas/deptry.git
# rev: "0.12.0"
# hooks:
# - id: deptry
# types: [python]
# detect-secrets
- repo: https://github.com/Yelp/detect-secrets
rev: 'v1.4.0'
hooks:
- id: detect-secrets
args: ['--exclude-lines', 'integrity=']
# yamllint
- repo: https://github.com/adrienverge/yamllint.git
rev: 'v1.35.1'
hooks:
- id: yamllint
args: ['-c', '.dev_config/.yamllint.yaml', '--strict']
# blocklint
- repo: https://github.com/PrincetonUniversity/blocklint
rev: 'v0.2.4'
hooks:
- id: blocklint
args: ['--skip-files=poetry.lock', '--max-issue-threshold=1']
# markdownlint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
args: ['--config', '.dev_config/.markdownlint.yaml', '--ignore', 'LICENSE.md', '--dot']
# standard
- repo: https://github.com/standard/standard
rev: v17.1.0
hooks:
- id: standard
# html5validator does not work with pre-commit since it checks modified files iteratively.
# Use `make html5validator` for local testing instead.
# prettier
# This pre-commit hook does not respect --ignore-path or --config,
# so we have to code the settings in here independently.
# It also runs quite slowly, so just use `make fmt_prettier` instead.
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: "v4.0.0-alpha.8"
# hooks:
# - id: prettier
# args: ['--no-config', '--print-width', '100', '--single-attribute-per-line']
# types_or: [html, css, scss, text]
# exclude: '.\.md|.\.yml|.\.yaml|.\.js|.\.min.css|Makefile'
# checkmake
- repo: https://github.com/mrtazz/checkmake.git
rev: '0.2.2'
hooks:
- id: checkmake
# shellcheck
- repo: https://github.com/koalaman/shellcheck-precommit
rev: 'v0.9.0'
hooks:
- id: shellcheck
# shfmt
- repo: https://github.com/scop/pre-commit-shfmt
rev: 'v3.8.0-1'
hooks:
- id: shfmt
args: ['-bn', '-ci', '-sr', '-s', '-w']
# typos
- repo: https://github.com/crate-ci/typos
rev: v1.19.0
hooks:
- id: typos
args: ["-c", "pyproject.toml"]
types: [text]
exclude: "^.*\\.kicad_.*$"
# github actions
- repo: https://github.com/rhysd/actionlint
rev: v1.6.27
hooks:
- id: actionlint
args: ['-ignore', 'SC2086']
# Clean carriage return and line feed
# https://github.com/Lucas-C/pre-commit-hooks
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
# - id: forbid-crlf
# exclude_types: [binary]
- id: remove-crlf
exclude_types: [binary]
# Clean unicode chars
# https://github.com/Lucas-C/pre-commit-hooks
- repo: local
hooks:
# - id: forbid-unicode-non-breaking-spaces
# name: Detect unicode non-breaking space character U+00A0 aka M-BM-
# language: system
# entry: perl -ne 'print if $m = /\xc2\xa0/; $t ||= $m; END{{exit $t}}'
# exclude_types: [binary]
# files: ''
- id: remove-unicode-non-breaking-spaces
name: Remove unicode non-breaking space character U+00A0 aka M-BM-
language: system
entry: perl -pi* -e 's/\xc2\xa0/ /g && ($t = 1) && print STDERR $_; END{{exit $t}}'
exclude_types: [binary]
files: ''
# - id: forbid-en-dashes
# name: Detect the EXTREMELY confusing unicode character U+2013
# language: system
# entry: perl -ne 'print if $m = /\xe2\x80\x93/; $t ||= $m; END{{exit $t}}'
# exclude_types: [binary]
# files: ''
- id: remove-en-dashes
name: Remove the EXTREMELY confusing unicode character U+2013
language: system
entry: perl -pi* -e 's/\xe2\x80\x93/-/g && ($t = 1) && print STDERR $_; END{{exit $t}}'
exclude_types: [binary]
files: ''
# No spaces in file names
# https://github.com/pre-commit/pre-commit-hooks/issues/736#issuecomment-1055989520
- repo: local
hooks:
- id: check-alphanumeric-filenames
name: filenames must be alphanumeric
language: fail
description: 'Filenames must be alphanumeric'
entry: 'filenames must be alphanumeric:'
exclude: '^[a-zA-Z0-9/\._-]+$'
# pygrep-hooks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 'v1.10.0'
hooks:
- id: python-check-blanket-noqa
name: check blanket noqa
description: 'Enforce that `noqa` annotations always occur with specific codes.'
entry: '(?i)# noqa(?!: )'
language: pygrep
types: [python]
- id: python-check-blanket-type-ignore
name: check blanket type ignore
description: 'Enforce that `# type: ignore` annotations always occur with specific codes.'
entry: '# type:? *ignore(?!\[|\w)'
language: pygrep
types: [python]
- id: python-check-mock-methods
name: check for not-real mock methods
description: >-
Prevent common mistakes of `assert mck.not_called()`, `assert mck.called_once_with(...)`
and `mck.assert_called`.
language: pygrep
entry: >
(?x)(
assert .*\.(
not_called|
called_
)|
# ''.join(rf'(?<!\b{s})' for s in dir(mock) if s.endswith('Mock')))
(?<!\bAsyncMock)(?<!\bMagicMock)(?<!\bMock)(?<!\bNonCallableMagicMock)(?<!\bNonCallableMock)(?<!\bPropertyMock)
\.assert_(
any_call|
called|
called_once|
called_once_with|
called_with|
has_calls|
not_called
)($|[^(\w])
)
types: [python]
- id: python-no-eval
name: check for eval()
description: 'A quick check for the `eval()` built-in function'
entry: '\beval\('
language: pygrep
types: [python]
- id: python-no-log-warn
name: use logger.warning(
description: 'A quick check for the deprecated `.warn()` method of python loggers'
entry: '(?<!warnings)\.warn\('
language: pygrep
types: [python]
- id: python-use-type-annotations
name: type annotations not comments
description: 'Enforce that python3.6+ type annotations are used instead of type comments'
entry: '# type(?!: *ignore([^a-zA-Z0-9]|$))'
language: pygrep
types: [python]
- id: rst-backticks
name: rst ``code`` is two backticks
description: 'Detect common mistake of using single backticks when writing rst'
entry: '^(?! ).*(^| )`[^`]+`([^_]|$)'
language: pygrep
types: [rst]
- id: rst-directive-colons
name: rst directives end with two colons
description: 'Detect mistake of rst directive not ending with :: or space before ::'
entry: '^\s*\.\. [a-z]+(| | :):$'
language: pygrep
types: [rst]
- id: rst-inline-touching-normal
name: rst ``inline code`` next to normal text
description: 'Detect mistake of inline code touching normal text in rst'
entry: '\w``\w'
language: pygrep
types: [rst]
- id: text-unicode-replacement-char
name: no unicode replacement chars
description: 'Forbid files which have a UTF-8 Unicode replacement character'
entry: "\uFFFD"
language: pygrep
types: [text]
# pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.5.0'
hooks:
#### python
# simply checks whether the files parse as valid python
- id: check-ast
# requires literal syntax when initializing empty or zero python builtin types
- id: check-builtin-literals
# checks for debugger imports and py37+ `breakpoint()` calls in python source
- id: debug-statements
# checks a common error of defining a docstring after code
- id: check-docstring-first
# verifies that test files are named correctly
- id: name-tests-test
#### files and file systems
# trims trailing whitespace
- id: trailing-whitespace
# ensures that a file is either empty, or ends with one newline
- id: end-of-file-fixer
# replaces or checks mixed line ending
- id: mixed-line-ending
args: ['--fix=lf']
# removes utf-8 byte order marker
- id: fix-byte-order-marker
# removes coding pragma from python files (useful in a python3-only codebase)
- id: fix-encoding-pragma
args: ['--remove']
# checks for files that would conflict in case-insensitive filesystems
- id: check-case-conflict
# checks for symlinks which do not point to anything
- id: check-symlinks
# detects symlinks which are changed to regular files with
# a content of a path which that symlink was pointing to
- id: destroyed-symlinks
# ensures that (non-binary) executables have a shebang
- id: check-executables-have-shebangs
# ensures that (non-binary) files with a shebang are executable
- id: check-shebang-scripts-are-executable
# sets a standard for formatting json files
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys']
#### parseable
# checks json files for parseable syntax
- id: check-json
# checks toml files for parseable syntax
- id: check-toml
# ensures that links to vcs websites are permalinks.
- id: check-vcs-permalinks
# checks xml files for parseable syntax
- id: check-xml
# checks yaml files for parseable syntax
- id: check-yaml
#### git
# don't commit to main
- id: no-commit-to-branch
args: ['--branch', 'main']
# checks for files that contain merge conflict strings
- id: check-merge-conflict
args: ['--assume-in-merge']
# prevents giant files from being committed
- id: check-added-large-files
args: ['--maxkb=128']
#### secrets
# detects *your* aws credentials from the aws cli credentials file
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
# detects the presence of private keys
- id: detect-private-key