-
-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
212 lines (186 loc) · 8.03 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
212 lines (186 loc) · 8.03 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
204
205
206
207
208
209
210
211
212
repos:
- repo: local
hooks:
# gen_requirements_all modifies files so it has to be first
- id: gen_requirements_all
name: gen_requirements_all
entry: scripts/run-in-env.sh -m scripts.gen_requirements_all
pass_filenames: false
language: system
types: [text]
files: ^(music_assistant/.+/manifest\.json|pyproject\.toml|\.pre-commit-config\.yaml|scripts/gen_requirements_all\.py)$
# build_translations_source regenerates the Lokalise source file from the per-module
# strings.json authoring files, so it also modifies files and must run early.
- id: build_translations_source
name: build_translations_source
entry: scripts/run-in-env.sh -m scripts.build_translations
pass_filenames: false
language: system
types: [text]
files: ^(music_assistant/strings\.json|music_assistant/.+/strings\.json|scripts/build_translations\.py)$
# fail when a ConfigEntry hardcodes label/description text instead of using strings.json
- id: check_config_entries
name: check_config_entries
entry: scripts/run-in-env.sh -m scripts.check_config_entries
pass_filenames: false
language: system
types: [python]
files: ^(music_assistant/.+\.py|scripts/check_config_entries\.py)$
- id: check-python-version
name: Validate pyproject.toml matches .python-version
entry: scripts/run-in-env.sh -m scripts.check_python_version
pass_filenames: false
language: system
files: ^(\.python-version|pyproject\.toml|scripts/check_python_version\.py)$
verbose: true # script overwrites pre-commit's metadata via ANSI escapes
# fail when a provider/controller test is a flat file instead of living in its own folder
- id: check_test_layout
name: check_test_layout
entry: scripts/run-in-env.sh -m scripts.check_test_layout
pass_filenames: false
language: system
files: ^(tests/(providers|controllers)/.+\.py|scripts/check_test_layout\.py)$
# fail when a provider manifest.json misses a mandatory key or is internally inconsistent
- id: check_manifests
name: check_manifests
entry: scripts/run-in-env.sh -m scripts.check_manifests
pass_filenames: true
language: system
types: [json]
files: ^music_assistant/providers/[^/]+/manifest\.json$
# fail when a provider/controller icon exceeds its size budget (existing offenders baselined)
- id: check_provider_icons
name: check_provider_icons
entry: scripts/run-in-env.sh -m scripts.check_provider_icons
pass_filenames: false
language: system
files: ^(music_assistant/(providers|controllers)/.+\.(svg|png)|scripts/check_provider_icons\.py|scripts/lint_baseline(s/oversized_provider_icons\.txt|\.py))$
# fail when a browse/recommendation folder hardcodes a label instead of using translation_key
- id: check_translatable_labels
name: check_translatable_labels
entry: scripts/run-in-env.sh -m scripts.check_translatable_labels
pass_filenames: true
language: system
types: [python]
files: ^music_assistant/providers/.+\.py$
# fail when code calls datetime.now()/utcnow() directly (existing call sites are baselined)
- id: check_datetime_helpers
name: check_datetime_helpers
entry: scripts/run-in-env.sh -m scripts.check_datetime_helpers
pass_filenames: false
language: system
types: [text]
files: ^(music_assistant/.+\.py|scripts/check_datetime_helpers\.py|scripts/lint_baseline(s/naive_datetime_usage\.txt|\.py))$
# fail when async code makes a known-blocking call (existing call sites are baselined)
- id: check_blocking_io
name: check_blocking_io
entry: scripts/run-in-env.sh -m scripts.check_blocking_io
pass_filenames: false
language: system
types: [text]
files: ^(music_assistant/.+\.py|scripts/check_blocking_io\.py|scripts/lint_baseline(s/blocking_io_in_async\.txt|\.py))$
# fail when a class puts a public/dunder method below a private one (existing classes baselined)
- id: check_method_order
name: check_method_order
entry: scripts/run-in-env.sh -m scripts.check_method_order
pass_filenames: false
language: system
types: [text]
files: ^(music_assistant/.+\.py|scripts/check_method_order\.py|scripts/lint_baseline(s/private_methods_not_last\.txt|\.py))$
- id: ruff-check
name: 🐶 Ruff Linter
language: system
types: [python]
entry: scripts/run-in-env.sh ruff check --fix
require_serial: true
stages: [pre-commit, pre-push, manual]
- id: ruff-format
name: 🐶 Ruff Formatter
language: system
types: [python]
entry: scripts/run-in-env.sh ruff format
require_serial: true
stages: [pre-commit, pre-push, manual]
- id: check-ast
name: 🐍 Check Python AST
language: system
types: [python]
entry: scripts/run-in-env.sh check-ast
- id: check-case-conflict
name: 🔠 Check for case conflicts
language: system
entry: scripts/run-in-env.sh check-case-conflict
- id: check-docstring-first
name: ℹ️ Check docstring is first
language: system
types: [python]
entry: scripts/run-in-env.sh check-docstring-first
- id: check-executables-have-shebangs
name: 🧐 Check that executables have shebangs
language: system
types: [text, executable]
entry: scripts/run-in-env.sh check-executables-have-shebangs
stages: [pre-commit, pre-push, manual]
- id: check-json
name: { Check JSON files
language: system
types: [json]
entry: scripts/run-in-env.sh check-json
files: ^(music_assistant/.+/manifest\.json)|(tests/providers/.+/fixtures/.+\.json)$
- id: check-merge-conflict
name: 💥 Check for merge conflicts
language: system
types: [text]
entry: scripts/run-in-env.sh check-merge-conflict
- id: check-symlinks
name: 🔗 Check for broken symlinks
language: system
types: [symlink]
entry: scripts/run-in-env.sh check-symlinks
- id: check-toml
name: ✅ Check TOML files
language: system
types: [toml]
entry: scripts/run-in-env.sh check-toml
- id: codespell
name: ✅ Check code for common misspellings
language: system
types: [text]
entry: scripts/run-in-env.sh codespell
- id: detect-private-key
name: 🕵️ Detect Private Keys
language: system
types: [text]
entry: scripts/run-in-env.sh detect-private-key
# frozen throwaway fixture key guarding Remote ID stability
exclude: ^tests/helpers/test_webrtc_certificate\.py$
- id: end-of-file-fixer
name: ⮐ Fix End of Files
language: system
types: [text]
entry: scripts/run-in-env.sh end-of-file-fixer
# downloaded Lokalise locale files don't carry a trailing newline; en.json's is
# guaranteed by build_translations (--check), so skip the whole translations dir
exclude: ^music_assistant/translations/
stages: [pre-commit, pre-push, manual]
- id: no-commit-to-branch
name: 🛑 Don't commit to stable branch
language: system
entry: scripts/run-in-env.sh no-commit-to-branch
pass_filenames: false
always_run: true
args:
- --branch=stable
- id: trailing-whitespace
name: ✄ Trim Trailing Whitespace
language: system
types: [text]
entry: scripts/run-in-env.sh trailing-whitespace-fixer
stages: [pre-commit, pre-push, manual]
- id: mypy
name: mypy
entry: scripts/run-in-env.sh mypy
language: system
types: [python]
require_serial: true
pass_filenames: false