-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
203 lines (197 loc) · 6.7 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
203 lines (197 loc) · 6.7 KB
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
default_install_hook_types:
- commit-msg
- post-checkout
- post-merge
- post-rewrite
- pre-commit
default_language_version:
python: python3.14
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.4.0
hooks:
- id: conventional-pre-commit
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleaks
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.6
hooks:
- id: remove-crlf
- id: remove-tabs
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.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
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
# python
- id: check-builtin-literals
- id: check-docstring-first
- id: name-tests-test
- repo: https://github.com/PyCQA/pylint
rev: v4.0.8
hooks:
- id: pylint
args:
- --max-line-length=79
- --max-module-lines=500
- --max-positional-arguments=10
- --max-args=10
- --score=n
- -d broad-except
- -d duplicate-code
- -d fixme
- -d invalid-name
- -d locally-disabled
- -d missing-docstring
- -d too-few-public-methods
- -d try-except-raise
- -d ungrouped-imports # conflicts with ruff isort
- -d wrong-import-order # conflicts with ruff isort
- repo: https://github.com/PyCQA/flake8
rev: 7.3.0
hooks:
- id: flake8
language: python
additional_dependencies:
- flake8-broken-line==1.0.0
- flake8-complicated-walrus==2.1.0
- flake8-import-restrictions==2.1
# TODO: consider switching to deptry
- flake8-requirements==2.3.0
args:
# https://www.flake8rules.com/
# Restrict flake8 to plugins with no ruff equivalent; core
# pyflakes/pycodestyle (E/W/F) are handled by ruff.
# FCW: flake8-complicated-walrus
# I90: flake8-requirements
# IMR: flake8-import-restrictions
# N400: flake8-broken-line
# IMR200: Imports should only happen on module level, not locally. Covered by pylint.
- --select=FCW,I90,IMR,N400
- --ignore=IMR200
- --imr241_exclude=collections.abc,typing
# TODO: use ruff once more refurb rules are out of preview
- repo: https://github.com/dosisod/refurb
rev: v2.3.1
hooks:
- id: refurb
args:
- --python-version
- '3.11'
- --
- --scripts-are-modules
# TODO: add more rules from https://docs.astral.sh/ruff/rules/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.8
hooks:
- id: ruff-check
args:
- --fix
- --target-version
- py311
- --select
- A,ANN,C4,C901,D,E,F,G010,I,PYI,RUF006,RUF100,S307,T10,TRY,UP,W,YTT
- --preview
- --config
- lint.mccabe.max-complexity = 10
# Codes owned by flake8 plugins with no ruff equivalent; keeps
# RUF100 from stripping their noqa directives.
- --config
- lint.external = ['FCW', 'I90', 'IMR', 'N400']
- --config
- lint.isort.force-single-line = true
# D1,D203,D205,D212,D400,D401,D404,D407,D412,D413: pydocstyle opinions.
# E501: Line too long. Covered by ruff format.
# E741: Do not use variables named 'I', 'O', or 'l'.
# TRY003: Avoid long messages outside the exception class.
# TRY301: Abstract raise to an inner function.
- --ignore
- D1,D203,D205,D212,D400,D401,D404,D407,D412,D413,E501,E741,TRY003,TRY301
- id: ruff-format
args:
- --config
- line-length = 79
- --config
- format.quote-style = 'single'
- --config
- format.skip-magic-trailing-comma = true
# Silence the isort/formatter magic-comma incompatibility warning.
- --config
- lint.isort.split-on-trailing-comma = false
- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2026.09.08
hooks:
- id: validate-pyproject
- repo: local
hooks:
- id: pyproject-no-unpinned-git-deps
name: disallow git dependencies without rev/tag
description: 'Disallow `[tool.uv.sources]` git dependencies unless they are pinned with a rev or tag on the same line'
# Flags lines that contain `git = "..."` but do NOT also contain `rev =` or `tag =`.
entry: '^(?!\s*#)(?=[^#]*\bgit\s*=\s*"[^"]+")(?![^#]*\b(?:rev|tag)\s*=).*$'
language: pygrep
types: [toml]
files: 'pyproject\.toml$'
- id: pyproject-no-unpinned-git-url-deps
name: disallow unpinned PEP 508 git URLs
description: 'Disallow `pkg @ git+<url>` direct references without an @<rev> pin'
# A pinned direct reference ends the git+ URL with `@<rev>`. This does
# not detect refs embedded in ssh URLs (`git+ssh://git@host/...`);
# prefer https direct references so the pin is unambiguous.
entry: '^(?!\s*#)(?=[^#]*git\+)(?![^#]*git\+[^\s"'',]+@[^\s"'',@/]+).*$'
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]
# json
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.38.0
hooks:
- id: check-circle-ci
- id: check-github-workflows
- id: check-renovate
language: python
additional_dependencies:
- pyjson5==2.0.1
# rst
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
# shell
- repo: https://github.com/openstack/bashate
rev: 2.1.1
hooks:
- id: bashate
args: [--max-line-length=80]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1-1
hooks:
- id: shellcheck
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: script-must-not-have-extension