/
/
/
1repos:
2 - repo: local
3 hooks:
4 # gen_requirements_all modifies files so it has to be first
5 - id: gen_requirements_all
6 name: gen_requirements_all
7 entry: scripts/run-in-env.sh -m scripts.gen_requirements_all
8 pass_filenames: false
9 language: system
10 types: [text]
11 files: ^(music_assistant/.+/manifest\.json|pyproject\.toml|\.pre-commit-config\.yaml|scripts/gen_requirements_all\.py)$
12
13 # build_translations_source regenerates the Lokalise source file from the per-module
14 # strings.json authoring files, so it also modifies files and must run early.
15 - id: build_translations_source
16 name: build_translations_source
17 entry: scripts/run-in-env.sh -m scripts.build_translations
18 pass_filenames: false
19 language: system
20 types: [text]
21 files: ^(music_assistant/strings\.json|music_assistant/.+/strings\.json|scripts/build_translations\.py)$
22
23 # fail when a ConfigEntry hardcodes label/description text instead of using strings.json
24 - id: check_config_entries
25 name: check_config_entries
26 entry: scripts/run-in-env.sh -m scripts.check_config_entries
27 pass_filenames: false
28 language: system
29 types: [python]
30 files: ^(music_assistant/.+\.py|scripts/check_config_entries\.py)$
31
32 - id: check-python-version
33 name: Validate pyproject.toml matches .python-version
34 entry: scripts/run-in-env.sh -m scripts.check_python_version
35 pass_filenames: false
36 language: system
37 files: ^(\.python-version|pyproject\.toml|scripts/check_python_version\.py)$
38 verbose: true # script overwrites pre-commit's metadata via ANSI escapes
39
40 # fail when a provider/controller test is a flat file instead of living in its own folder
41 - id: check_test_layout
42 name: check_test_layout
43 entry: scripts/run-in-env.sh -m scripts.check_test_layout
44 pass_filenames: false
45 language: system
46 files: ^(tests/(providers|controllers)/.+\.py|scripts/check_test_layout\.py)$
47
48 # fail when a provider manifest.json misses a mandatory key or is internally inconsistent
49 - id: check_manifests
50 name: check_manifests
51 entry: scripts/run-in-env.sh -m scripts.check_manifests
52 pass_filenames: true
53 language: system
54 types: [json]
55 files: ^music_assistant/providers/[^/]+/manifest\.json$
56
57 # fail when a provider/controller icon exceeds its size budget (existing offenders baselined)
58 - id: check_provider_icons
59 name: check_provider_icons
60 entry: scripts/run-in-env.sh -m scripts.check_provider_icons
61 pass_filenames: false
62 language: system
63 files: ^(music_assistant/(providers|controllers)/.+\.(svg|png)|scripts/check_provider_icons\.py|scripts/lint_baseline(s/oversized_provider_icons\.txt|\.py))$
64
65 # fail when a browse/recommendation folder hardcodes a label instead of using translation_key
66 - id: check_translatable_labels
67 name: check_translatable_labels
68 entry: scripts/run-in-env.sh -m scripts.check_translatable_labels
69 pass_filenames: true
70 language: system
71 types: [python]
72 files: ^music_assistant/providers/.+\.py$
73
74 # fail when code calls datetime.now()/utcnow() directly (existing call sites are baselined)
75 - id: check_datetime_helpers
76 name: check_datetime_helpers
77 entry: scripts/run-in-env.sh -m scripts.check_datetime_helpers
78 pass_filenames: false
79 language: system
80 types: [text]
81 files: ^(music_assistant/.+\.py|scripts/check_datetime_helpers\.py|scripts/lint_baseline(s/naive_datetime_usage\.txt|\.py))$
82
83 # fail when async code makes a known-blocking call (existing call sites are baselined)
84 - id: check_blocking_io
85 name: check_blocking_io
86 entry: scripts/run-in-env.sh -m scripts.check_blocking_io
87 pass_filenames: false
88 language: system
89 types: [text]
90 files: ^(music_assistant/.+\.py|scripts/check_blocking_io\.py|scripts/lint_baseline(s/blocking_io_in_async\.txt|\.py))$
91
92 # fail when a class puts a public/dunder method below a private one (existing classes baselined)
93 - id: check_method_order
94 name: check_method_order
95 entry: scripts/run-in-env.sh -m scripts.check_method_order
96 pass_filenames: false
97 language: system
98 types: [text]
99 files: ^(music_assistant/.+\.py|scripts/check_method_order\.py|scripts/lint_baseline(s/private_methods_not_last\.txt|\.py))$
100
101 - id: ruff-check
102 name: ð¶ Ruff Linter
103 language: system
104 types: [python]
105 entry: scripts/run-in-env.sh ruff check --fix
106 require_serial: true
107 stages: [pre-commit, pre-push, manual]
108
109 - id: ruff-format
110 name: ð¶ Ruff Formatter
111 language: system
112 types: [python]
113 entry: scripts/run-in-env.sh ruff format
114 require_serial: true
115 stages: [pre-commit, pre-push, manual]
116
117 - id: check-ast
118 name: ð Check Python AST
119 language: system
120 types: [python]
121 entry: scripts/run-in-env.sh check-ast
122
123 - id: check-case-conflict
124 name: ð Check for case conflicts
125 language: system
126 entry: scripts/run-in-env.sh check-case-conflict
127
128 - id: check-docstring-first
129 name: â¹ï¸ Check docstring is first
130 language: system
131 types: [python]
132 entry: scripts/run-in-env.sh check-docstring-first
133
134 - id: check-executables-have-shebangs
135 name: ð§ Check that executables have shebangs
136 language: system
137 types: [text, executable]
138 entry: scripts/run-in-env.sh check-executables-have-shebangs
139 stages: [pre-commit, pre-push, manual]
140
141 - id: check-json
142 name: ï½ Check JSON files
143 language: system
144 types: [json]
145 entry: scripts/run-in-env.sh check-json
146 files: ^(music_assistant/.+/manifest\.json)|(tests/providers/.+/fixtures/.+\.json)$
147
148 - id: check-merge-conflict
149 name: ð¥ Check for merge conflicts
150 language: system
151 types: [text]
152 entry: scripts/run-in-env.sh check-merge-conflict
153
154 - id: check-symlinks
155 name: ð Check for broken symlinks
156 language: system
157 types: [symlink]
158 entry: scripts/run-in-env.sh check-symlinks
159
160 - id: check-toml
161 name: â
Check TOML files
162 language: system
163 types: [toml]
164 entry: scripts/run-in-env.sh check-toml
165
166 - id: codespell
167 name: â
Check code for common misspellings
168 language: system
169 types: [text]
170 entry: scripts/run-in-env.sh codespell
171
172 - id: detect-private-key
173 name: ðµï¸ Detect Private Keys
174 language: system
175 types: [text]
176 entry: scripts/run-in-env.sh detect-private-key
177 # frozen throwaway fixture key guarding Remote ID stability
178 exclude: ^tests/helpers/test_webrtc_certificate\.py$
179
180 - id: end-of-file-fixer
181 name: â® Fix End of Files
182 language: system
183 types: [text]
184 entry: scripts/run-in-env.sh end-of-file-fixer
185 # downloaded Lokalise locale files don't carry a trailing newline; en.json's is
186 # guaranteed by build_translations (--check), so skip the whole translations dir
187 exclude: ^music_assistant/translations/
188 stages: [pre-commit, pre-push, manual]
189
190 - id: no-commit-to-branch
191 name: ð Don't commit to stable branch
192 language: system
193 entry: scripts/run-in-env.sh no-commit-to-branch
194 pass_filenames: false
195 always_run: true
196 args:
197 - --branch=stable
198
199 - id: trailing-whitespace
200 name: â Trim Trailing Whitespace
201 language: system
202 types: [text]
203 entry: scripts/run-in-env.sh trailing-whitespace-fixer
204 stages: [pre-commit, pre-push, manual]
205
206 - id: mypy
207 name: mypy
208 entry: scripts/run-in-env.sh mypy
209 language: system
210 types: [python]
211 require_serial: true
212 pass_filenames: false
213