-
Notifications
You must be signed in to change notification settings - Fork 27
/
.pre-commit-config.yaml
204 lines (191 loc) · 8.85 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
# 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
# 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 implementation, tox runs 'pre-commit run -a'
# To manually run without committing > pre-commit run --all-files
minimum_pre_commit_version: 3.4.0 # 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: v4.6.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
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 # have no toml files
# 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 # have no yaml files
# 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]
# - id: no-commit-to-branch
# description: Protect specific branches from direct checkins.
# - id: pretty-format-json
# 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-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
- repo: local
hooks:
- 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] (flake8)
description: Code linter
entry: flake8 # https://gitlab.com/pycqa/flake8
additional_dependencies: [flake8]
language: python
types: [python]
require_serial: true
args: [--max-line-length, '120']
- id: mypy # https://github.com/python/mypy
name: Static typing for Python (mypy)
entry: mypy
additional_dependencies: [mypy, pytest, types-backports]
language: python
types: [python]
args: [--show-error-codes]
# Not using the below as it removes 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]
# - repo: https://github.com/pycqa/doc8
# rev: 0.9.0a1
# hooks:
# - id: doc8
# args: [--max-line-length, '120']
# name: Check for style in rst documentation (doc8)
# description: Documentation linter
# - repo: local
# hooks:
# - id: python -m sphinx.apidoc
# name: Build autodoc API subdirectory (sphinx-apidoc)
# entry: sphinx-apidoc
# args: [-f, -e, -T, -o, docs\_api, webchanges]
# language: system
# - repo: local
# hooks:
# - id: sphinx-build
# name: Check documentation build (sphinx-build)
# entry: python -m sphinx.cmd.build
# args: [-a, -E, -W, docs, docs/_build]
# language: system
# files: ^docs
# types: [file]
# 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]
# language: system
# files: ^docs
# types: [file]
# pass_filenames: false
- repo: local
hooks:
- id: sort_and_fix
name: Sort database and fix data precision
entry: python pre-commit/sort_and_fix.py
language: system
pass_filenames: false
- id: update_readme_counts
name: Update database counts in README.rst
entry: python pre-commit/update_readme_counts.py
language: system
pass_filenames: false