-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.pre-commit-config.yaml
178 lines (178 loc) · 6.57 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
# See https://pre-commit.com for more information
default_language_version:
# default exe name
python: python
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-yaml
- id: check-xml
- id: check-json
- id: check-executables-have-shebangs
- id: mixed-line-ending
- id: pretty-format-json
args:
- --autofix
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
name: black
language: python
types: [python]
args:
- "--line-length=80"
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
hooks:
- id: yamllint
language: python
types: [file, yaml]
args:
- -d
- "{extends: default, rules: {line-length: disable}}"
- repo: https://github.com/openstack-dev/bashate
rev: 2.1.1
hooks:
- id: bashate
# Run bashate check for all bash scripts
# Ignores the following rules:
# E006: Line longer than 79 columns (as many scripts use jinja
# templating, this is very difficult)
# E040: Syntax error determined using `bash -n` (as many scripts
# use jinja templating, this will often fail and the syntax
# error will be discovered in execution anyway)
entry: bashate --error . --verbose --ignore=E006,E040
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
language: python
types: [python]
args:
- --ignore=D212,D203
- repo: https://github.com/pycqa/pylint
rev: v3.0.2
hooks:
- id: pylint
language: python
types: [python]
args:
- --rcfile=pylintrc
- "--jobs" # spawning multiple processes
- "0" # 0 will auto-detect the number of processors available to use
- --max-args
- "100"
- --max-nested-blocks
- "10"
- --max-branches
- "12"
- --max-statements
- "100"
- --max-returns
- "1"
- --max-module-lines
- "1000"
- --include-naming-hint
- "yes"
- --spelling-private-dict-file=pylint_dict.txt
- --enable=use-symbolic-message-instead
- --enable=useless-suppression
- --enable=fixme
- --disable=missing-function-docstring # C0116
- --disable=line-too-long # C0301
- --disable=wrong-import-order # C0411
- --disable=wrong-import-position # C0413
- --disable=import-outside-toplevel # C0415
- --disable=import-error # E0401
- --disable=no-name-in-module # E0611
- --disable=no-member # E1101
- --disable=too-many-function-args # E1121
- --disable=consider-using-from-import # E0012
- --disable=c-extension-no-member # I1101
- --disable=too-many-instance-attributes # R0902
- --disable=too-many-locals # R0914
- --disable=fixme # W0511
- --disable=global-statement # W0603
- --disable=global-at-module-level # W0604
- --disable=broad-except # W0703
- --disable=logging-format-interpolation # W1202
- --disable=logging-fstring-interpolation # W1203
- --disable=too-few-public-methods # R0903
- --disable=format # handled by black
- --disable=deprecated-typing-alias # R6001
- --disable=consider-using-alias # R6002
- --disable=consider-alternative-union-syntax # R6003
- --disable=consider-using-assignment-expr # R6103 - walrus
- --disable=duplicate-code # R0801
- --disable=protected-access # W0212
additional_dependencies:
- pyenchant # spelling for pylint
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
hooks:
- id: mypy
# requires lots of packages installed
language: system
# https://towardsdatascience.com/modernize-your-sinful-python-code-with-beautiful-type-hints-4e72e98f6bf1
# https://towardsdatascience.com/how-to-make-python-statically-typed-the-essential-guide-e087cf4fa400
# https://github.com/samuelcolvin/pydantic/blob/master/setup.cfg#L51
# https://news.ycombinator.com/item?id=27737014
args:
- --config-file=mypy.ini # exclusions
- --strict # turns on most other options
- --warn-unreachable
#
# https://linuxtut.com/en/8104ebcaa8ba8803259c/ Summary of options not enabled by `--strict`
# options not in strict
# - --disallow-any-unimported
# - --disallow-any-decorated
# - --disallow-any-explicit
# - --disallow-any-expr
# - --warn-incomplete-stub
#
# revert some options in strict
#
# - --ignore-missing-imports
# https://mypy.readthedocs.io/en/stable/running_mypy.html
# This flag makes mypy ignore all missing imports. It is equivalent to adding # type: ignore comments to all unresolved imports within your codebase.
# https://github.com/indigoviolet/mypy-missing-imports
#
# REQUIRED to live with --strict
- --allow-untyped-decorators
- --allow-redefinition
- --allow-any-generics
- --no-warn-return-any # requires all types known
- --disable-error-code=union-attr
# helpful for --strict
- --disable-error-code=attr-defined
- --disable-error-code=assignment
- --disable-error-code=var-annotated
# - --disable-error-code=arg-type
# - --disable-error-code=return-value
# - --disable-error-code=valid-type
# - --disable-error-code=name-defined
# - --disable-error-code=no-untyped-def
# - --disable-error-code=call-overload
# - --disable-error-code=no-untyped-call
# need this with MYPYPATH=$PYTHONPATH
- --namespace-packages
- --explicit-package-bases
# turn on stuff we like
- --python-version=3.9
- --scripts-are-modules
- --show-error-codes
types: [python]