-
Notifications
You must be signed in to change notification settings - Fork 7
/
.pre-commit-config.yaml
317 lines (277 loc) · 7.35 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
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
minimum_pre_commit_version: '2.9.2'
default_language_version:
python: python3
default_stages: [commit]
repos:
# Meta checks
- repo: meta
hooks:
- id: check-useless-excludes
# General fixers
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
exclude_types: [svg]
- id: mixed-line-ending
name: Normalize mixed line endings
args: [--fix=lf]
exclude_types: [batch]
- id: end-of-file-fixer
exclude_types: [svg]
- id: fix-byte-order-marker
name: Remove Unicode BOM
# More general fixers
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
hooks:
- id: remove-tabs
name: Replace tabs with spaces
types: [text]
exclude_types: [svg, batch]
args: [--whitespaces-count, '4']
# Check and fix spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
# Define separate hooks for checking and correcting spelling errors
# since codespell doesn't print verbose output when writing changes
- id: codespell
name: Check spelling
exclude: '\.gitattributes'
args: ['-L', 'complet,generat']
- id: codespell
name: Fix spelling
exclude: '\.gitattributes'
args: ['-L', 'complet,generat', --write-changes]
# Pretty-format INI
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.1.0
hooks:
- id: pretty-format-ini
name: Format INI
types: [ini]
args: [--autofix]
# Check JSON
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-json
# Add doctoc to Markdown
- repo: https://github.com/thlorenz/doctoc
rev: v2.0.1
hooks:
- id: doctoc
name: Generate Markdown ToCs
args: [--maxlevel, '3', --update-only]
# Lint Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.28.1
hooks:
- id: markdownlint
name: Lint Markdown
args: [--fix]
# Format packaging
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
hooks:
- id: setup-cfg-fmt
name: Format packaging with setup-cfg-fmt
# Check packaging
- repo: https://github.com/regebro/pyroma
rev: '3.2'
hooks:
- id: pyroma
# Fix Python
- repo: https://github.com/asottile/pyupgrade
rev: v2.24.0
hooks:
- id: pyupgrade
name: Fix Python with Pyupgrade
args: ['--py37-plus', '--keep-runtime-typing']
- repo: local
hooks:
- id: fixit
name: Fix Python with FixIt
entry: python -m fixit.cli.apply_fix
language: python
types: [python]
require_serial: true
additional_dependencies:
- 'fixit == 0.1.4'
- repo: https://github.com/hakancelik96/unimport
rev: '0.8.3'
hooks:
- id: unimport
name: Fix Python with Unimport
args: [--remove]
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
hooks:
- id: remove-crlf
name: Replace CRLF with LF post-Unimport
types: [python]
# Format Python
- repo: https://github.com/psf/black
rev: '21.7b0'
hooks:
- id: black
name: Format Python with Black
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/pycqa/isort
rev: '5.9.3'
hooks:
- id: isort
name: Format Python imports with isort
# Check Python
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-ast
name: Check Python
- id: name-tests-test
name: Check that test files start with test
args: ['--django']
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-type-ignore
name: Check blanket type ignore
- id: python-check-mock-methods
name: Check for bad mock methods
- id: python-no-log-warn
name: Check for logger.warn
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: v1.2.1
hooks:
- id: python-safety-dependencies-check
name: Run Safety check on dependencies
files: 'requirements.txt'
# Lint Python
- repo: https://github.com/pycqa/flake8
rev: '3.9.2'
hooks:
- id: flake8
name: Lint Python with Flake8
require_serial: true
additional_dependencies:
- 'dlint == 0.11.0'
- 'flake8-2020 == 1.6.0'
- 'flake8-pytest-style == 1.5.0'
- 'pydocstyle == 6.1.1'
- 'wemake-python-styleguide == 0.15.3'
- repo: https://github.com/PyCQA/bandit
rev: '1.7.0'
hooks:
- id: bandit
name: Lint Python security with Bandit
args: ['-c', '.bandit.yml']
require_serial: true
- repo: local
hooks:
- id: check-env-activated
name: Check that a suitable Python env is activated
entry: 'python tools/check_env_activated.py'
language: system
types: [python]
pass_filenames: false
- id: enable-praw-typehints
name: Enable PRAW type hints
entry: 'python tools/enable_praw_typehints.py'
language: system
types: [python]
pass_filenames: false
- id: mypy
name: Lint Python with MyPy
entry: 'mypy .'
language: system
types: [python]
pass_filenames: false
- id: pyanalyze
name: Lint Python with PyAnalyze
entry: 'python -b -X dev -W error -m pyanalyze .'
args: [--autofix, --enable-all, '-d', invalid_annotation, '-d', unsupported_operation]
language: system
types: [python]
pass_filenames: false
- id: pylint
name: Lint Python with Pylint
entry: pylint
language: system
types: [python]
# Check TOML
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-toml
# Pretty-format YAML
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.1.0
hooks:
- id: pretty-format-yaml
name: Format Yaml
args: [--autofix, --indent, '2', --preserve-quotes]
# Check YAML
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
# Lint YAML
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.3
hooks:
- id: yamllint
name: Lint Yaml
types: [yaml]
args: [-s, -f, colored]
# Replace CRLF with LF post-prettify
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
hooks:
- id: remove-crlf
name: Replace CRLF with LF post-prettify
types: [text]
exclude_types: [batch]
# General checkers
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: text-unicode-replacement-char
name: Check for Unicode replacement chars
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-added-large-files
args: [--maxkb=1025]
- id: check-case-conflict
- id: check-executables-have-shebangs
exclude: 'pre\-commit\-config\.yaml'
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-symlinks
- id: destroyed-symlinks
name: Detect destroyed symlinks
- id: detect-private-key
# - id: no-commit-to-branch
# name: Prevent commits to wrong branch
# args: [--branch, master, --pattern, 'v?\d{1,3}\.x']
# Commit message hooks #
# Check that commit message follows basic rules
- repo: https://github.com/jorisroovers/gitlint
rev: v0.15.1
hooks:
- id: gitlint
name: Check commit message
# Check commit message spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
name: Check commit message spelling
stages: [commit-msg]