-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.pre-commit-config.yaml
224 lines (215 loc) · 10 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
# Configuration for pre-commit (see https://pre-commit.com/)
# A framework for managing and maintaining multi-language pre-commit hooks.
# List of hooks at https://pre-commit.com/hooks.html
# Prefer using local configurations as they don't have to be constantly auto-updated (slow).
# Local configuration follows the repo's .pre-commit-hooks.yaml
# Requires the pre-commit package manager to be installed: pip install pre-commit
# To install pre-commit into your git hooks (i.e. at .git/hooks/pre-commit), run 'pre-commit install'.
# To update hooks to the latest version automatically, run 'pre-commit autoupdate'. By default, this will bring the
# hooks to the latest tag on the default branch.
# NOTE: in this package tox runs 'pre-commit run -a'
minimum_pre_commit_version: 3.7.1 # based on what's available at https://pre-commit.ci/
# Force all unspecified python hooks to run python3
default_language_version:
python: python3
# A list of repository mappings.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# see https://github.com/pre-commit/pre-commit-hooks
# - id: check-added-large-files
# description: Prevent giant files from being committed.
# - id: check-ast # black takes care of this
# description: Simply check whether files parse as valid python.
- id: check-builtin-literals
description: Require literal syntax when initializing empty or zero Python builtin types.
- id: check-case-conflict
description: Check for files with names that would conflict on a case-insensitive filesystem.
# - id: check-docstring-first # black takes care of this
# description: Checks for a common error of placing code before the docstring.
- id: check-executables-have-shebangs
description: Checks that non-binary executables have a proper shebang.
# - id: check-json # have no json files
# description: Attempts to load all json files to verify syntax.
- id: check-merge-conflict
description: Check for files that contain merge conflict strings.
# - id: check-shebang-scripts-are-executable # have none
# description: Checks that scripts with shebangs are executable.
# - id: check-symlinks
# description: Checks for symlinks which do not point to anything.
- id: check-toml
description: Attempts to load all TOML files to verify syntax.
- id: check-vcs-permalinks
description: Ensures that links to vcs websites are permalinks.
# - id: check-xml # have no xml files
# description: Attempts to load all xml files to verify syntax.
- id: check-yaml
args: [--allow-multiple-documents]
description: Attempts to load all yaml files to verify syntax.
- id: debug-statements
description: Check for debugger imports and py37+ breakpoint() calls in python source.
- id: destroyed-symlinks
description: >-
Detects symlinks which are changed to regular files with a content of a path which that symlink was
pointing to.
# - id: detect-aws-credentials # have none
# description: Checks for the existence of AWS secrets that you have set up with the AWS CLI.
# - id: detect-private-key # have none
# description: Checks for the existence of private keys.
- id: double-quote-string-fixer
description: This hook replaces double quoted strings with single quoted strings.
- id: end-of-file-fixer
description: Makes sure files end in a newline and only a newline.
# - id: file-contents-sorter
# description: Sort the lines in specified files (defaults to alphabetical).
- id: fix-byte-order-marker
description: removes UTF-8 byte order marker
- id: fix-encoding-pragma
args: [--remove]
description: "Remove # -*- coding: utf-8 -*- from the top of python files"
# - id: forbid-new-submodules
# description: Prevent addition of new git submodules
- id: forbid-submodules
description: forbids any submodules in the repository.
# - id: mixed-line-ending # are using gitattributes https://git-scm.com/docs/gitattributes
# args: [--fix=lf]
# description: Forces replacing of line ending by the UNIX 'lf' character
- id: name-tests-test
description: verifies that test files are named correctly.
args: [--pytest-test-first]
exclude: ^tests/data/hooks_example.py # a RegExp
# - id: no-commit-to-branch
# description: Protect specific branches from direct checkins.
# - id: pretty-format-json # have none
# description: Checks that all your JSON files are pretty.
- id: requirements-txt-fixer
description: Sorts entries in requirements.txt and removes incorrect entry for pkg-resources==0.0.0
# - id: sort-simple-yaml
# description: Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks.
# - id: trailing-whitespace # removes trailing whitespace from test files too!
# description: Trims trailing whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
description: >-
"Enforce that noqa annotations always occur with specific codes. Sample annotations: # noqa: F401, # noqa:
F401,W203"
- id: python-check-blanket-type-ignore
description: >-
"Enforce that # type: ignore annotations always occur with specific codes. Sample annotations: # type:
ignore[attr-defined], # type: ignore[attr-defined, name-defined]"
- id: python-check-mock-methods
description: >-
Prevent common mistakes of assert mck.not_called(), assert mck.called_once_with(...) and mck
.assert_called
- id: python-no-eval
description: A quick check for the eval() built-in function
- id: python-no-log-warn
description: A quick check for the deprecated .warn() method of python loggers
- id: python-use-type-annotations
description: Enforce that python3.6+ type annotations are used instead of type comments
- id: rst-backticks
description: Detect common mistake of using single backticks when writing rst
- id: rst-directive-colons
description: Detect mistake of rst directive not ending with double colon
# - id: rst-inline-touching-normal
# description: Detect mistake of inline code touching normal text in rst
- id: text-unicode-replacement-char
description: Forbid files which have a UTF-8 Unicode replacement character
exclude: ^CHANGELOG.rst|^RELEASE.rst
- repo: local
hooks:
# - id: bandit # https://github.com/PyCQA/bandit
# name: Find common security issues in Python code (bandit)
# entry: bandit
# additional_dependencies: [bandit]
# language: python
# types: [python]
# args: [--ini, .bandit, --recursive]
- id: isort # https://github.com/PyCQA/isort
name: isort your imports, so you don't have to (isort)
entry: isort
require_serial: true
additional_dependencies: [isort]
language: python
types_or: [cython, pyi, python]
args: [--filter-files]
- id: flynt # https://github.com/ikamensh/flynt
name: convert % strings to f-strings (flynt)
entry: flynt
additional_dependencies: [flynt]
language: python
require_serial: true
types: [python]
args: [--fail-on-change]
- id: black # https://github.com/python/black
name: uncompromising code formatting (black)
entry: black
additional_dependencies: [black]
language: python
types: [python]
- id: flake8
name: check for errors, style [and over-complexity], security (flake8, bandit)
description: Code linter
entry: flake8 # https://gitlab.com/pycqa/flake8
additional_dependencies: [flake8, flake8-bandit, flake8-quotes]
language: python
types: [python]
require_serial: true
args: [--max-line-length, '120']
- id: mypy # https://github.com/python/mypy
name: check Python static typing (mypy)
entry: mypy
additional_dependencies:
- mypy
- types-backports
- types-docutils
- types-python-dateutil
- types-PyYAML
- types-redis
- types-requests
- types-simplejson
language: python
types: [python]
- id: doc8 # https://github.com/pycqa/doc8
name: check for style in rst documentation (doc8)
description: Documentation linter
entry: doc8
additional_dependencies: [doc8]
language: python
types: [rst]
require_serial: true
args: [--max-line-length, '120']
# Not running tox-ini-fmt as it removes all remarks
# - id: tox-ini-fmt # https://github.com/tox-dev/tox-ini-fmt
# name: Apply a consistent format to tox.ini files (tox-ini-fmt)
# entry: tox-ini-fmt
# additional_dependencies: [tox-ini-fmt]
# language: python
# files: tox.ini
# types: [ini]
# - id: python -m sphinx.apidoc
# name: Build autodoc API subdirectory (sphinx-apidoc)
# entry: sphinx-apidoc
# args: [-f, -e, -T, -o, docs\_api, webchanges]
# additional_dependencies: [sphinx]
# language: system
# - id: sphinx-build
# name: Check documentation build (sphinx-build)
# entry: python -m sphinx.cmd.build
# args: [-W, docs, docs/_build]
# additional_dependencies: [sphinx]
# language: system
# pass_filenames: false
# # https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html#module-sphinx.ext.doctest
# - id: sphinx-doctest
# name: sphinx doctest
# entry: python -m sphinx-build
# args: [-a, -E, -b, doctest, docs, docs/_build]
# additional_dependencies: [sphinx]
# language: system
# files: ^docs
# types: [file]
# pass_filenames: false