-
Notifications
You must be signed in to change notification settings - Fork 92
/
.pre-commit-config.yaml
215 lines (210 loc) · 6.34 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
ci:
autofix_commit_msg: 'refactor(lint): apply automatic lint fixes'
autoupdate_commit_msg: 'chore(deps): bump pre-commit linter versions'
default_language_version:
python: python3.8
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents]
- id: detect-private-key
exclude: (auth/tests/unit/token_test.py)|(storage/gcloud/aio/storage/blob.py)
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
# python
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: debug-statements
- id: double-quote-string-fixer
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/pylint
rev: v3.2.7
hooks:
# TODO: re-enable pylint-import-modules when it supports pylint v3
- id: pylint
args:
- --load-plugins=pylint.extensions.mccabe
- --max-complexity=10
- --max-line-length=79
- --max-args=10
- --score=n
- -d broad-except
- -d broad-exception-raised # TODO: fixme
- -d duplicate-code
- -d fixme
- -d import-error
- -d invalid-name
- -d locally-disabled
- -d missing-docstring
- -d too-few-public-methods
- -d too-many-arguments # we generally match args to the Google APIs
- -d try-except-raise
- -d ungrouped-imports # conflicts with reorder-python-imports
- -d wrong-import-order # conflicts with reorder-python-imports
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-crlf
- id: remove-tabs
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.14.0
hooks:
- id: reorder-python-imports
args: [--py38-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- &mypy
id: mypy
name: mypy-auth
require_serial: True
# N.B. mypy requires an installed version of whatever third-party
# library it is asked to check against. In practice, that means
# whenever we see an error telling us to do so, we should add the
# relevant library to `additional_dependencies`.
# Note that some libraries keep their type hints in packages named
# `types-$lib` or `$lib-stubs`.
additional_dependencies:
- aiohttp
- backoff
- types-cryptography
- types-jwt
- types-requests
args:
- --show-error-codes
- --strict
- --strict-equality
- --warn-unreachable
files: auth/
exclude: tests/
- <<: *mypy
name: mypy-bigquery
additional_dependencies:
- aiohttp
- gcloud-aio-auth
- types-requests
files: bigquery/
- <<: *mypy
name: mypy-datastore
additional_dependencies:
- aiohttp
- gcloud-aio-auth
- types-requests
files: datastore/
- <<: *mypy
name: mypy-kms
additional_dependencies:
- aiohttp
- gcloud-aio-auth
- types-requests
files: kms/
- <<: *mypy
name: mypy-pubsub
additional_dependencies:
- aiohttp
- gcloud-aio-auth
- prometheus-client
- types-requests
files: pubsub/
- <<: *mypy
name: mypy-storage
additional_dependencies:
- aiohttp
- gcloud-aio-auth>=5.3.0
- rsa
- types-aiofiles
- types-requests
files: storage/
- <<: *mypy
name: mypy-taskqueue
additional_dependencies:
- aiohttp
- gcloud-aio-auth
- types-requests
files: taskqueue/
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
# N.B. keep these in sync with flake8, otherwise yesqa will remove
# required noqa's related to these plugins
additional_dependencies: &flake8deps
- flake8-2020==1.8.1
- flake8-broken-line==1.0.0
- flake8-builtins==2.1.0
- flake8-commas==2.1.0
- flake8-comprehensions==3.13.0
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
args: [-a, -i, -p2]
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: *flake8deps
args:
- --ignore=E501,W503,F401,F811
- repo: local
hooks:
- id: poetry-check
name: check pyproject.toml validity
description: 'Validate the structure of the pyproject.toml file'
entry: bash -c 'set -e; for toml in "$@"; do pushd ./${toml%pyproject.toml}; poetry check; popd; done' --
language: python
additional_dependencies:
- poetry>=1.2.0
pass_filenames: true
files: 'pyproject\.toml$'
- id: poetry-use-version-ranges
name: avoid using carets for version ranges
description: 'Avoid using carets for version ranges'
entry: '\^'
language: pygrep
types: [toml]
files: 'pyproject.toml$'
- id: pytest-fixtures-require-scope
name: ensure pytest fixture scopes are explicitly set
description: 'Ensure we explicitly set pytest fixture scopes'
entry: '@pytest\.fixture( |\n|(\(\)))'
language: pygrep
types: [python]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
# rst
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
# json
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
hooks:
- id: check-github-workflows
- id: check-renovate
additional_dependencies:
- pyjson5