Commit b170f7b
chore(dev): add standalone pre-commit check script
Merge #6084
## Summary
Adds `scripts/run_precommit_checks.py` to run the `.pre-commit-config.yaml` checks **without** the `pre-commit` framework, which requires a git repository and so cannot run in environments such as a piper checkout that has no `.git`.
- Parses `.pre-commit-config.yaml` so the file lists, global/per-hook `exclude` and `files` patterns, and `args` all come from the config — only the hook-id → CLI command mapping (and each hook's implicit file-type/text filter) is maintained in the script.
- Defaults to fixing in place; pass `--check` to verify only (CI behavior).
- Limits the walk to `src`/`tests`/`contributing`/`pyproject.toml` and never follows symlinks, so `.venv`, build artifacts, and out-of-repo code (e.g. a symlinked `a2a`) are never touched.
- Skips binary files for text fixers, and batches arguments to stay under the OS arg limit.
- `scripts/run_precommit.sh` is a thin wrapper that prefers an already-synced interpreter (`.venv` / active venv) before falling back to `uv run`.
- Adds the standalone lint tools to the `dev` extra (capped at the next major) so `uv sync --extra dev` provides everything the script needs.
## Test plan
- [ ] `scripts/run_precommit.sh --check` passes on a clean tree
- [ ] `scripts/run_precommit.sh` (default fix mode) does not modify binaries (images/PDFs) or `.venv`
- [ ] Runs from any directory; PATH args are repo-root-relative
- [ ] `addlicense` / `check-new-py-prefix` degrade gracefully when unavailable / git-only
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=#6084 from google:chore/dev-precommit-script fa38633
PiperOrigin-RevId: 9307997851 parent 62808f7 commit b170f7b
5 files changed
Lines changed: 483 additions & 113 deletions
File tree
- .agents/skills/adk-unit-guide
- scripts
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
| |||
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
| |||
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
61 | | - | |
62 | 59 | | |
63 | 60 | | |
64 | 61 | | |
| |||
94 | 91 | | |
95 | 92 | | |
96 | 93 | | |
97 | | - | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
101 | 97 | | |
102 | | - | |
103 | 98 | | |
104 | 99 | | |
105 | 100 | | |
106 | | - | |
107 | 101 | | |
108 | 102 | | |
109 | 103 | | |
110 | 104 | | |
111 | | - | |
112 | 105 | | |
113 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
117 | 118 | | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
121 | | - | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
| |||
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
160 | | - | |
161 | 159 | | |
162 | 160 | | |
163 | 161 | | |
| |||
180 | 178 | | |
181 | 179 | | |
182 | 180 | | |
183 | | - | |
184 | 181 | | |
185 | 182 | | |
186 | 183 | | |
187 | 184 | | |
188 | | - | |
189 | 185 | | |
190 | 186 | | |
191 | 187 | | |
| |||
248 | 244 | | |
249 | 245 | | |
250 | 246 | | |
251 | | - | |
252 | 247 | | |
253 | | - | |
254 | 248 | | |
255 | 249 | | |
256 | 250 | | |
257 | | - | |
258 | 251 | | |
259 | 252 | | |
260 | 253 | | |
261 | 254 | | |
262 | 255 | | |
263 | 256 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
271 | 262 | | |
272 | 263 | | |
273 | 264 | | |
274 | | - | |
275 | 265 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 266 | + | |
| 267 | + | |
282 | 268 | | |
283 | 269 | | |
| 270 | + | |
| 271 | + | |
284 | 272 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | 273 | | |
289 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
290 | 281 | | |
291 | 282 | | |
292 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments