z43-hooks 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. z43_hooks-0.1.0/PKG-INFO +7 -0
  2. z43_hooks-0.1.0/README.md +318 -0
  3. z43_hooks-0.1.0/pyproject.toml +47 -0
  4. z43_hooks-0.1.0/setup.cfg +4 -0
  5. z43_hooks-0.1.0/tests/test_audit_cli.py +668 -0
  6. z43_hooks-0.1.0/tests/test_audit_stub_cli.py +223 -0
  7. z43_hooks-0.1.0/tests/test_autofix.py +381 -0
  8. z43_hooks-0.1.0/tests/test_change_gate.py +385 -0
  9. z43_hooks-0.1.0/tests/test_checks.py +692 -0
  10. z43_hooks-0.1.0/tests/test_config_activation.py +482 -0
  11. z43_hooks-0.1.0/tests/test_cpp_include_cli.py +537 -0
  12. z43_hooks-0.1.0/tests/test_cpp_include_group_cli.py +677 -0
  13. z43_hooks-0.1.0/tests/test_cpp_include_order_cli.py +565 -0
  14. z43_hooks-0.1.0/tests/test_cpp_parse.py +340 -0
  15. z43_hooks-0.1.0/tests/test_cpp_rules_cli.py +297 -0
  16. z43_hooks-0.1.0/tests/test_house_rules_cli.py +437 -0
  17. z43_hooks-0.1.0/tests/test_pybind_rules_cli.py +510 -0
  18. z43_hooks-0.1.0/tests/test_z43_checks_cli.py +368 -0
  19. z43_hooks-0.1.0/z43_hooks/__init__.py +11 -0
  20. z43_hooks-0.1.0/z43_hooks/audit.py +1039 -0
  21. z43_hooks-0.1.0/z43_hooks/audit_stub.py +471 -0
  22. z43_hooks-0.1.0/z43_hooks/autofix.py +55 -0
  23. z43_hooks-0.1.0/z43_hooks/change_gate.py +255 -0
  24. z43_hooks-0.1.0/z43_hooks/checks.py +973 -0
  25. z43_hooks-0.1.0/z43_hooks/config.py +343 -0
  26. z43_hooks-0.1.0/z43_hooks/core.py +461 -0
  27. z43_hooks-0.1.0/z43_hooks/cpp_include.py +1790 -0
  28. z43_hooks-0.1.0/z43_hooks/cpp_include_data.py +331 -0
  29. z43_hooks-0.1.0/z43_hooks/cpp_parse.py +377 -0
  30. z43_hooks-0.1.0/z43_hooks/cpp_pybind.py +1198 -0
  31. z43_hooks-0.1.0/z43_hooks/cpp_rules.py +408 -0
  32. z43_hooks-0.1.0/z43_hooks/fixers.py +872 -0
  33. z43_hooks-0.1.0/z43_hooks/tools.py +243 -0
  34. z43_hooks-0.1.0/z43_hooks.egg-info/PKG-INFO +7 -0
  35. z43_hooks-0.1.0/z43_hooks.egg-info/SOURCES.txt +37 -0
  36. z43_hooks-0.1.0/z43_hooks.egg-info/dependency_links.txt +1 -0
  37. z43_hooks-0.1.0/z43_hooks.egg-info/entry_points.txt +5 -0
  38. z43_hooks-0.1.0/z43_hooks.egg-info/requires.txt +2 -0
  39. z43_hooks-0.1.0/z43_hooks.egg-info/top_level.txt +1 -0
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: z43-hooks
3
+ Version: 0.1.0
4
+ Summary: Sim4Life repo-standard C++/Python checks and change gate (pre-commit hooks).
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: tree-sitter
7
+ Requires-Dist: tree-sitter-cpp
@@ -0,0 +1,318 @@
1
+ # z43-hooks
2
+
3
+ Repo-standard C++/Python checks and the change gate used by
4
+ `SuperMash/git_hooks/.pre-commit-config.yaml` (hosted repo, pinned by tag).
5
+ One checker dispatches by file suffix; one `[tool.z43]` table in a repo's
6
+ `pyproject.toml` is the only place rules are activated, tightened, or
7
+ excluded; one report/exit-code contract runs through every entry point.
8
+
9
+ - `z43-checks` - rules ruff cannot express, over any mix of paths. `.py`
10
+ files get the stdlib-AST Python rules (missing `Final`, singleton naming,
11
+ assert/`# nosec` placement, single-use TypeVar, advisory
12
+ NamedTuple/module-length); C/C++ files (`.cpp .cxx .cc .h .hpp .hxx .inl`)
13
+ route to the C++ rule registry (empty until the C++ rule tickets land, so
14
+ they yield nothing today). `--fix` applies the mechanical fixes,
15
+ `--unsafe-fixes` adds the rename tier, `--dry-run` previews the `--fix`
16
+ counts without writing. `--select`/`--ignore` choose codes
17
+ or category stems for one run; `--list-codes` prints the rule map. The
18
+ path-level `path-space` check judges every path it is given, whatever the
19
+ file type - directory arguments see only the checkable suffixes, so the
20
+ pre-commit hook (which passes every staged file individually) is the
21
+ complete sweep. Exit:
22
+ 0 clean, 1 findings, 2 the run was degraded (a file could not be seen at
23
+ all) - never a silent zero.
24
+ - `z43-change-gate` - runs ruff + bandit + the checks above and reports only
25
+ findings on lines added by the staged diff (advisory `info` findings join
26
+ the report only with `--include-info`). One policy inversion:
27
+ `nosec-redundant` never blocks a commit - dead-`# nosec` cleanup is driven
28
+ by whole-file `z43-checks --fix`, so a per-commit diff gate must not wait
29
+ on it. Path-level codes (`path-space`) bypass the added-line filter: a
30
+ staged path is being committed now, whether or not its content changed.
31
+ Exit: 0 clean, 1 findings on added lines, 2 a tool or the staged
32
+ diff could not run.
33
+ - `z43-cpp-include` - the deterministic include normalizer (see below).
34
+ Check-by-default; `--fix` is the only writer.
35
+ - `z43-audit` - the deep audit the incremental gate cannot be: whole-tree
36
+ pybind sweeps (docstring layout, Raises: attribution, entity guards, weak
37
+ types) and, under `z43-audit stubs MODULE`, the generated `.pyi` side.
38
+ `--ignore CATEGORY` reports a category but never gates on it; exit:
39
+ 0 clean, 1 findings, 2 degraded.
40
+
41
+ `z43_hooks/autofix.py` remains an importable module (its `main()` still
42
+ runs the same fix pipeline); its old standalone console script is gone with
43
+ no alias - use `z43-checks --fix`.
44
+
45
+ `z43_hooks/audit.py` keeps its own category vocabulary (the codes above are
46
+ the per-line gate rules; the audit's heuristics - `weak-type`,
47
+ `legacy-enum`, `export-values`, `unchecked-entity-deref`,
48
+ `missing-raises-section`, `split-docstring-literal`, `bad-none-default`,
49
+ `cpp-name-in-docstring`, ... - are whole-tree findings) with severities
50
+ `defect` (gates) / `review` / `artifact` / `defer` / `info` (advisory,
51
+ `--include-info`). `--ignore <category>` reports the category in full but
52
+ never gates on it, so a verification pass can measure a grandfathered family
53
+ without failing on it: `export-values` is measured every run and its site
54
+ count is printed even when the category is ignored. The same marker dialect
55
+ applies: `// z43: ignore[code]` on the flagged line or inside the owning
56
+ `.def(...)` downgrades a defect to info (`[suppressed]`).
57
+
58
+ ## Rule map
59
+
60
+ Every shipped rule is a declaration in the registry `z43_hooks.core.RULES`
61
+ (code, level, scope, fix tier). Discover it from the tool: `z43-checks --list-codes --format json`.
62
+
63
+ | Code | Level | Scope | Fix tier | Fires on |
64
+ | ---------------------- | ----- | -------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65
+ | `final-missing` | error | all | safe | a module-level binding never rebound and never mutated after the bind, not `Final` (except-handler and `__main__`-guard binds exempt) |
66
+ | `final-maybe-missing` | error | all | unsafe | a never-rebound binding whose object is mutated after the bind (attr/subscript store, or a container mutator on a container-literal bind) - `Final` is advisory there |
67
+ | `naming-module` | error | all | unsafe | an `UPPER_CASE` name bound to a singleton instance |
68
+ | `nosec-missing` | error | all | safe | an `assert` in non-test code with no `# nosec` |
69
+ | `nosec-redundant` | error | all | safe | a `# nosec` in a test file (bandit skips tests) |
70
+ | `typevar-single-use` | error | all | report-only | a `TypeVar` used once in a signature |
71
+ | `tuple-namedtuple` | info | all | report-only | a multi-field `tuple[...]` return, advisory |
72
+ | `module-length` | info | all | report-only | a module past the soft line limit, advisory |
73
+ | `suppression-unused` | error | all | safe | a `# z43: ignore` marker that covers nothing |
74
+ | `path-space` | error | all | report-only | a staged path with a space in the file or folder name (any file type; unwaivable by marker - no line owns a path) |
75
+ | `virtual-redundant` | error | all | safe | a C++ member declared `virtual` with `override`/`final` |
76
+ | `ns-using` | error | all | report-only | a file-scope `using namespace` in a C++ header |
77
+ | `str-wide-concat` | error | all | safe | a multi-line wide-string concat repeating the `L` prefix |
78
+ | `throw-type` | error | pyd-only | unsafe | a bare `std::runtime_error` whose message complains about input (the rewrite to `XCORE_VALIDATE_NOT` changes the Python-visible type) |
79
+ | `throw-macro-spelling` | info | pyd-only | safe | a correct-type throw spelled raw instead of `XCORE_RAISE_IF`/`XCORE_VALIDATE_NOT` |
80
+ | `throw-macro` | info | all | safe | a call site of an ad-hoc throw macro the shared `<XCore/CommonMacros.h>` replaces |
81
+ | `throw-macro-broken` | error | all | report-only | a `#define` throwing `std::runtime_error(os)` with no `os` (instantiation cannot compile), and its call sites |
82
+ | `enum-export-values` | error | pyd-only | unsafe (diff-gated) | a `.export_values()` call — measured whole-file, gated on added lines |
83
+ | `doc-split` | error | pyd-only | safe | a binding docstring split across adjacent string literals |
84
+ | `doc-multiline` | error | pyd-only | safe | a `\n`-escaped prose docstring literal (safe only when delimiter-safe) |
85
+ | `doc-long` | info | pyd-only | report-only | a binding docstring past 4000 characters, advisory |
86
+ | `lambda-long` | info | pyd-only | report-only | a `.def` lambda past the `[tool.z43.checks.lambda-long]` line limit, advisory |
87
+ | `lambda-passthrough` | info | pyd-only | report-only | a single-call-body `.def` lambda (excepting `py::init` and `cls`-absorbing static-property getters) |
88
+
89
+ Level: `error` fails a run, `info` is advisory and never does (pass
90
+ `--include-info` to see it). Scope: `all` checks every file of the language;
91
+ a `pyd-only` scope fires only under a `pyd` directory segment. Fix tier:
92
+ `safe` runs under `--fix`, `unsafe` needs `--unsafe-fixes`, `report-only`
93
+ (None) never rewrites. `diff-gated` codes are reported and counted by
94
+ whole-file `z43-checks` without failing it (legacy sites stay visible, they
95
+ do not block), while `z43-change-gate` fires them on lines a commit adds.
96
+
97
+ ## Activation model
98
+
99
+ `[tool.z43.checks]` in the nearest repo `pyproject.toml` that carries a
100
+ `[tool.z43]` table (walked up from each target path - nested per-package
101
+ pyprojects without a table are stepped over, ruff's rule for `[tool.ruff]`,
102
+ so a monorepo's build files never shadow the repo's activation) is the single
103
+ source of what is enforced. The pre-commit hook passes no selection args, so
104
+ the hook, an editor, a CLI run, and CI never disagree:
105
+
106
+ ```toml
107
+ [tool.z43]
108
+ # Only build/ and .mypy_cache/ ship built-in; every vendored tree is named
109
+ # here (fragments match any single path segment, case-insensitively).
110
+ exclude = ["build", ".mypy_cache", "vendor_dir", "gen-py"]
111
+ extend-exclude = ["generated"] # APPENDS instead of replacing (ruff semantics)
112
+
113
+ [tool.z43.checks]
114
+ select = ["final-missing", "throw-type"] # explicit activation (see below)
115
+ ignore = ["naming-module"] # opt codes/stems out repo-wide
116
+ strict = ["B024", "F822"] # replaces the gate's ruff zero-tolerance set
117
+ strict-cpp = ["virtual-redundant"] # replaces the C++ zero-tolerance set
118
+ ```
119
+
120
+ `select` is the activation list: with it, only the listed codes/stems run;
121
+ without it, every registered rule stays active. A new built-in rule does not
122
+ go live in a configured repo until the repo adds it, exactly like
123
+ `[tool.ruff.lint] select`. `ignore` still overrides select (ruff's order).
124
+
125
+ CLI `--select`/`--ignore` override the table for one run only. Matching is
126
+ at hyphen boundaries: `--ignore nosec` covers `nosec-missing` and
127
+ `nosec-redundant`; `--select final` covers `final-missing` and
128
+ `final-maybe-missing`, a bare `fin` matches nothing. Exclusions are forced
129
+ everywhere, the fix pipeline
130
+ included: neither `z43-checks --fix` nor the autofix module writes into an
131
+ excluded tree (a stderr note, not a silent skip), and an explicitly passed
132
+ vendored path is still skipped from checks. Any directory below the config
133
+ root that ships its own `.clang-format` auto-skips as vendored.
134
+
135
+ ## The include normalizer (`z43-cpp-include`)
136
+
137
+ Three stages share one tool: **normalize** (fix the include *string*:
138
+ case-correctness against headers on disk, main-header quoting, clear
139
+ quoting violations), **group** (bucket partition, blank-line structure)
140
+ and **order** (sort WITHIN buckets). `--stage` accepts `normalize`
141
+ (default), `group`, `order` and `all`; `all` runs normalize THEN group
142
+ THEN order in memory and writes the combined result once (for
143
+ already-normalized modules - the safe rollout path stays one stage per
144
+ commit). Normalize is line-local and never relocates an include; group
145
+ relocates lines but never rewrites a string; order permutes includes in
146
+ place within each bucket's written lines (structure untouched).
147
+
148
+ - **check mode is the default** and writes nothing: exit 1 on any
149
+ would-change (a string rewrite for normalize, a line that moves for
150
+ group), exit 0 with visible warnings otherwise, exit 2 for a degraded
151
+ run (unreadable file, bad `--roots`). `--fix` is the only writer and
152
+ exits by leftovers (0 all applied, 1 could-not-apply or leftover, 2
153
+ degraded). `--dry-run` prints per-category/per-module counts;
154
+ `--format json` renders per-file changes `{line, category, from, to}`
155
+ and moves `{line, from_bucket, to_bucket}` plus the counts.
156
+ - **case**: an include matching an on-disk header only case-insensitively
157
+ is rewritten to the disk casing (Linux builds break on the wrong case),
158
+ for angle and quoted forms and module-qualified paths alike.
159
+ - **quoting**: the TU's own header (`Foo.cpp` -> `Foo.h`; the `*_pyd.h`
160
+ module header in `pyd` dirs) must be a quoted local include, and a
161
+ quoted include that resolves under an index root becomes the angle
162
+ form. A relative `"../Foo.h"` stays quoted - nothing is guessed.
163
+ - **unresolved**: an include resolving nowhere and not a known system /
164
+ third-party / order-sensitive (ACIS-family) spelling is warned with a
165
+ per-module count, never rewritten - and warnings alone never fail a run.
166
+ - **group buckets**, in emitted order: (0) the TU's pinned main header,
167
+ (1) repo-local - resolves under the edited file's own repo root, or a
168
+ relative `"../Foo.h"` that stays inside it, (2) second-party - resolves
169
+ under a *different* `--roots` root (the repo split derives from the
170
+ file's path, never from config), (3) third-party - a configured
171
+ `thirdparty_groups` prefix or order-sensitive (ACIS) spelling, and
172
+ (4) system/STL. **An include that resolves nowhere lands in bucket 3**:
173
+ the conservative bucket, because an unresolvable target looks like a
174
+ library header. No line is ever dropped.
175
+ - **blank-line structure is exact**: one blank line between non-empty
176
+ buckets, none inside one; trailing `//` comments ride with their
177
+ include; everything outside an include region is untouched.
178
+ - **hard boundaries** the tool never crosses: conditional-inclusion arms
179
+ (each `#if`/`#else`/`#elif` arm groups independently inside the arm),
180
+ `extern "C"` blocks, pragmas, comment lines, and real code.
181
+ - **pch**: a precompiled-header include at position 0 of the include
182
+ block (any spelling whose basename is a known PCH, including a
183
+ relative `"../PreCompiled.h"`) is canonical bucket-0 content: never a
184
+ would-change, never relocated, never judged - the delete-vs-keep
185
+ decision is a human audit. A PCH-named include anywhere ELSE is an
186
+ ordinary include: bucketed like any header, NOT moved to position 0.
187
+ - Group operates on canonical strings (run normalize first, or
188
+ `--stage all`); run standalone on mis-cased includes it still groups
189
+ correctly - classification is case-folded - and the would-change list
190
+ just carries the moves.
191
+ - **order sorts WITHIN each bucket** (after grouping; it never moves an
192
+ include across a bucket or a hard boundary, and the position-0 PCH pin
193
+ stays put). Repo-local and second-party includes are ranked by COARSE
194
+ naming-convention **tiers** from `[tool.z43.includes] tier_order` (an
195
+ ordered glob list like `XCore*`, `xcoremath`, `*`), alphabetical within
196
+ a tier; a NEW module matching an existing tier glob lands in that tier
197
+ automatically, and an unmatched module sorts after every named tier
198
+ (never dropped - the property that keeps the tier list maintenance-
199
+ free). The **third-party** bucket is sorted in configured per-library
200
+ sub-blocks (`thirdparty_groups` order: boost, Eigen, VTK, pybind, ACIS,
201
+ ...) alphabetical within, unmatched third-party after the configured
202
+ groups; the **system** bucket is alphabetical. Every sort is
203
+ case-insensitive with the written position as a stable tiebreak, so
204
+ output is deterministic across platforms.
205
+ - **order-sensitive carve-out**: an include matching an
206
+ `[tool.z43.includes] order_sensitive` pattern (the ACIS api/error
207
+ family: `<api.err>`, `*.hxx`, `Windows.h`) is FIXED in its written
208
+ line - excluded from any sort, so its relative order with the rest of
209
+ the family survives normalize+group+order unchanged (the macro-ordering
210
+ contract). Adding a pattern to `order_sensitive` in a repo's table
211
+ protects a new family the same way. The ACIS undefinition header
212
+ (`UndefACIS.h`) is pinned **last** within the third-party bucket (it
213
+ redefines the error macros, so it must follow every header consuming
214
+ them).
215
+ - Index roots = the nearest `pyproject.toml` dir plus `--roots` repeats;
216
+ the shared exclude/auto-skip layer applies and excluded trees are never
217
+ even indexed (a vendored path passed explicitly stays skipped, exit
218
+ unchanged).
219
+
220
+ The report categories (`case`, `quoting`, `pch`, `unresolved`, `moves`,
221
+ `reorders`, `kept`) are REPORT CATEGORIES with counts - not rule codes:
222
+ no registry entry, no per-line `z43: ignore` suppression, and the code
223
+ table above is unchanged. `[tool.z43.includes]` (`tier_order` /
224
+ `thirdparty_groups` / `order_sensitive`) replaces the shipped defaults
225
+ wholesale; the defaults live in `z43_hooks/cpp_include_data.py`, measured
226
+ off the real trees. Output is idempotent (`stage(stage(x)) == stage(x)`
227
+ for each stage and
228
+ for `all`) and clang-format idempotent under the consumer `.clang-format`
229
+ files (include
230
+ sorting stays off there - the two tools never fight).
231
+
232
+ ## Fix safety
233
+
234
+ Like ruff, fixes are tiered (the tiers live in the same rule registry):
235
+
236
+ | Tier | Codes | Contract |
237
+ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
238
+ | safe (`--fix`) | `final-missing`, `nosec-missing`, `nosec-redundant`, `suppression-unused`, `virtual-redundant`, `str-wide-concat`, `throw-macro-spelling`, `throw-macro`, `doc-split`, `doc-multiline` | only adds/removes what the checker prescribes; semantics cannot change |
239
+ | unsafe (`--unsafe-fixes`) | `naming-module`, `final-maybe-missing`, `throw-type`, `enum-export-values` | renames the singleton and same-file usages / annotates `Final` on a binding whose object is mutated / changes the Python-visible exception type / deletes public enum names - review the diff |
240
+ | report-only | `typevar-single-use`, `tuple-namedtuple`, `module-length`, `ns-using`, `throw-macro-broken`, `doc-long`, `lambda-long`, `lambda-passthrough` | needs judgement |
241
+
242
+ Every Python edit must keep the file `compile()`-able, and every C++ edit
243
+ must re-parse with no new grammar error nodes, or it is skipped and counted.
244
+ After fixing, the fix pipeline best-effort sorts imports via
245
+ `ruff check --fix --select I` when ruff is on PATH.
246
+
247
+ The C++ front end (tree-sitter, a hard dependency) counts grammar error nodes
248
+ per run and surfaces them in the report footer only - macro-heavy headers
249
+ never flood the report or fail a run.
250
+
251
+ The gate's tool invocations live in `z43_hooks/tools.py` (one seam for
252
+ ruff/bandit/git, unpinned - bump by rebuilding the hook env). When a tool
253
+ cannot run, the gate says so on stderr and exits 2 instead of passing the
254
+ commit on silence.
255
+
256
+ ## Suppressing a finding
257
+
258
+ mypy-style, on the offending line (comment position only - prose about the
259
+ syntax is not a marker):
260
+
261
+ ```python
262
+ MAX = 3 # z43: ignore[final-missing] one code
263
+ X = f() # z43: ignore[final-missing, naming-module]
264
+ Y = g() # z43: ignore every z43 code on this line
265
+ ```
266
+
267
+ C++ uses the same dialect in `//` comments (scanned inside comment spans
268
+ only, so a marker inside a string or raw-string body is never a marker):
269
+
270
+ ```cpp
271
+ virtual Foo() override; // z43: ignore[virtual-redundant]
272
+ ```
273
+
274
+ For the binding-tree (pyd) codes, a marker anywhere inside the owning
275
+ `.def(...)` call covers every finding in that call - one ignore comment
276
+ tames a whole lambda body instead of one line:
277
+
278
+ ```cpp
279
+ m.def("go", [](int n) {
280
+ // z43: ignore[throw-type]
281
+ if (n < 0) throw std::runtime_error("n must be >= 0");
282
+ return n;
283
+ }, "Go.");
284
+ ```
285
+
286
+ A marker whose listed code covers nothing is reported as
287
+ `suppression-unused` (ruff's RUF100 analogue) - and `--fix` prunes it, so
288
+ stale ignores cannot accumulate.
289
+
290
+ Path-level codes are the dialect's limit made explicit: a finding with no
291
+ source line (`path-space`) can carry no marker, so the footer offers no
292
+ waiver hint for it. `ignore` in `[tool.z43.checks]` (or `--ignore`) opts it
293
+ out - the config layer, not a line comment.
294
+
295
+ `path-space` is adapted from [check-spaces-in-paths](https://github.com/dyollb/check-spaces-in-paths)
296
+ (MIT, Bryn Lloyd) - rewritten for this rule registry, not copied.
297
+
298
+ Develop:
299
+
300
+ ```bash
301
+ python -m pip install pre-commit && pre-commit install
302
+ pre-commit run --all-files # or: python -m pytest -q, ruff check .
303
+ ```
304
+
305
+ `.pre-commit-config.yaml` is this repo's own standard ruff-based config.
306
+
307
+ Release: bump `version` in `pyproject.toml`, then tag `vX.Y.Z` matching it
308
+ and push the tag. The CI (`.gitlab-ci.yml`) runs the tests and publishes the
309
+ wheel to this project's PyPI package registry. Bump the `rev:` in the
310
+ consumer config afterwards.
311
+
312
+ Install a published version (replace `<PROJECT_ID>` with this project's
313
+ numeric id, shown on the project overview page):
314
+
315
+ ```bash
316
+ pip install z43-hooks \
317
+ --index-url https://git.speag.com/api/v4/projects/<PROJECT_ID>/packages/pypi/simple
318
+ ```
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "z43-hooks"
7
+ version = "0.1.0"
8
+ description = "Sim4Life repo-standard C++/Python checks and change gate (pre-commit hooks)."
9
+ requires-python = ">=3.11"
10
+ # Deliberately unpinned; both ship abi3 wheels, so hook venvs, dev venvs and
11
+ # both CI lanes install them identically.
12
+ dependencies = [
13
+ "tree-sitter",
14
+ "tree-sitter-cpp",
15
+ ]
16
+
17
+ [project.scripts]
18
+ z43-checks = "z43_hooks.checks:main"
19
+ z43-change-gate = "z43_hooks.change_gate:main"
20
+ z43-cpp-include = "z43_hooks.cpp_include:main"
21
+ z43-audit = "z43_hooks.audit:main"
22
+
23
+ [tool.setuptools.packages.find]
24
+ include = ["z43_hooks*"]
25
+
26
+ [tool.mypy]
27
+ python_version = "3.11"
28
+ # build/ holds a stale copy of the package (duplicate-module error).
29
+ files = ["z43_hooks", "tests"]
30
+ exclude = ["^build/"]
31
+
32
+ # Named modules only - a global ignore_missing_imports would hide real
33
+ # missing stubs. tree-sitter ships py.typed, so this only quiets envs
34
+ # where the deps are absent (e.g. bare mypy runs).
35
+ [[tool.mypy.overrides]]
36
+ module = ["tree_sitter", "tree_sitter_cpp", "pytest"]
37
+ ignore_missing_imports = true
38
+
39
+ [tool.ruff]
40
+ target-version = "py311"
41
+ line-length = 88
42
+
43
+ [tool.ruff.lint]
44
+ select = ["E", "F", "I", "UP", "B", "ANN", "SIM"]
45
+
46
+ [tool.ruff.lint.per-file-ignores]
47
+ "tests/**" = ["ANN001", "ANN002", "ANN201", "ANN202"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+