-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
257 lines (221 loc) · 7.99 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
---
minimum_pre_commit_version: "2.17"
default_stages: [commit]
ci:
skip: [mypy, pylint, python-safety-dependencies-check, flakeheaven]
repos:
# ----------------------------------------------
# Meta hooks
# ----------------------------------------------
- repo: meta
hooks:
- id: identity
stages: [commit, manual]
- id: check-hooks-apply
stages: [manual]
- id: check-useless-excludes
stages: [manual]
# ----------------------------------------------
# File hooks
# ----------------------------------------------
# file checking out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-case-conflict
- id: check-shebang-scripts-are-executable
# ----------------------------------------------
# Dependency hooks
# ----------------------------------------------
# safety - python dependency vulnerability checker
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: 3f01891d76160f03e9134ef025fb1eb1d10c85a2 # frozen: v1.3.3
hooks:
- id: python-safety-dependencies-check
args: ["--disable-optional-telemetry", "--full-report", "--ignore=51457"]
files: pyproject.toml
exclude: testing
# ####################################################################################
#
# FORMATTING
#
# ####################################################################################
# ----------------------------------------------
# Python
# ----------------------------------------------
# pyupgrade - upgrade old syntax to new
- repo: https://github.com/asottile/pyupgrade
rev: 12af25eb252deaaecb6b259df40d01f42e716dc3 # frozen: v3.15.2
hooks:
- id: pyupgrade
args: ["--py37-plus"]
# isort - sort imports
- repo: https://github.com/PyCQA/isort
rev: c235f5e450b4b84e58d114ed4c589cbf454175a3 # frozen: 5.13.2
hooks:
- id: isort
# black - python formatter
- repo: https://github.com/psf/black
rev: 3702ba224ecffbcec30af640c149f231d90aebdb # frozen: 24.4.2
hooks:
- id: black
args: ["--safe"]
# blacken-docs - black for python code in docs (rst/md/tex)
- repo: https://github.com/asottile/blacken-docs
rev: 960ead214cd1184149d366c6d27ca6c369ce46b6 # frozen: 1.16.0
hooks:
- id: blacken-docs
exclude: testing|tests
# ----------------------------------------------
# JS / TS / HTML / CSS / MD / JSON / YAML
# ----------------------------------------------
# prettier - multi formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
hooks:
- id: prettier
# ----------------------------------------------
# Spelling dict
# ----------------------------------------------
# Custom hook as python command
- repo: local
hooks:
- id: sort-spelling-dicts
name: Sort spelling_dict.txt files
description: Sort spelling_dict.txt files
language: python
entry: python
args:
- "-c"
- |
import pathlib;
import sys;
p = pathlib.Path(sys.argv[1]);
p.write_text("\n".join(sorted(set(p.read_text("utf-8").splitlines()))) + "\n", "utf-8")
files: "spelling_dict.txt"
# ----------------------------------------------
# General (code unspecific)
# ----------------------------------------------
# code unspecific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: end-of-file-fixer
stages: [commit]
- id: trailing-whitespace
stages: [commit]
# ####################################################################################
#
# LINTING
#
# ####################################################################################
# ----------------------------------------------
# General (code unspecific)
# ----------------------------------------------
- repo: local
hooks:
# Find TODO:|FIXME:|BUG: comments in all files
# Inline skip: `#i#` directly after the colon after the tag-word
- id: find-todos
name: "Find TODO:|FIXME:|BUG: comments"
description: "Check for TODO:|FIXME:|BUG: comments in all files"
language: pygrep
entry: '(^|//!?|#|<!--|;|/\*(\*|!)?|\.\.)\s*(TODO:|FIXME:|BUG:)(?!#i#)'
exclude: TODO
# code unspecific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-merge-conflict
- id: detect-private-key
# ----------------------------------------------
# Python
# ----------------------------------------------
# python specific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
- id: name-tests-test
args: ["--django"]
# several python code regex hooks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
# flakeheaven - wrapper for flake8
- repo: https://github.com/flakeheaven/flakeheaven
rev: 289c489c9654342dae2ad871527c5951acb2f22d # frozen: 3.3.0
hooks:
- id: flakeheaven
types: [python]
additional_dependencies:
- "git+https://github.com/cielquan/[email protected]"
# Lint hooks managed via tox envs b/c they need the pkg installed
- repo: local
hooks:
# mypy - python type checker
- id: mypy
name: mypy
description: run mypy over the installed package via tox
entry: tox
args: ["-e", "mypy"]
language: python
additional_dependencies: [tox]
types: [python]
pass_filenames: false
require_serial: true
# pylint - python linter
- id: pylint
name: pylint
description: run pylint over the installed package via tox
entry: tox
args: ["-e", "pylint", "--"]
language: python
additional_dependencies: [tox]
types: [python]
require_serial: true
# poetry - python dependency management
- repo: https://github.com/Cielquan/mirrors-poetry
rev: ec25c4d5817d8bcf1d6251c347a1892cb817edb8 # frozen: 1.8.2
hooks:
- id: poetry-check
# ----------------------------------------------
# reStructuredText
# ----------------------------------------------
# rstcheck - rst file checker
- repo: https://github.com/rstcheck/rstcheck
rev: 445861c31d8134562e723d77115721038de2e687 # frozen: v6.2.0
hooks:
- id: rstcheck
args: ["--config", "pyproject.toml"]
additional_dependencies: [tomli, sphinx]
exclude: testing
# ----------------------------------------------
# Markdown
# ----------------------------------------------
# markdownlint - md file checker
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: 24eb4dce508ab81398d14d75179123fca425f12d # frozen: v0.13.0
hooks:
- id: markdownlint-cli2
# ----------------------------------------------
# TOML / YAML
# ----------------------------------------------
# JSON specific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
# yamllint - yaml linter
- repo: https://github.com/adrienverge/yamllint
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # frozen: v1.35.1
hooks:
- id: yamllint