ADR-338: Wire mypy --strict static analysis into ml/ build#244
ADR-338: Wire mypy --strict static analysis into ml/ build#244jodavis-claude wants to merge 3 commits into
Conversation
Adds mypy==2.3.0 to ml/requirements.txt and a greenfield ml/pyproject.toml with [tool.mypy] strict = true (python_version 3.12, no blanket ignore_missing_imports so later tasks handle untyped imports explicitly per-import). Adds scripts/validate-ml-build.sh/.cmd, modeled on validate-build.sh/.cmd, running mypy --strict pipeline test from ml/. Wires it into scripts/validate.sh/.cmd after validate-build, and lists it in CLAUDE.md's Quality Gates table. Adds empty ml/pipeline/__init__.py and ml/test/__init__.py package markers so the strict-mode scan has files to check against an otherwise-empty tree.
core.filemode=false in this container caused git add to record the new script as 100644 despite the chmod +x on disk; explicitly set it to match validate-build.sh's mode.
…ktree The .NET SDK's bundled Microsoft.Build.Tasks.Git.targets fails with "Unsupported repository extension 'relativeworktrees'" when building from this worktree, because newer git versions set that extension on worktree checkouts and the SDK-pinned task (fixed upstream only in the 10.0.2xx SDK line, see dotnet/sourcelink#1468) does not recognize it. This broke scripts/validate-build.sh for every project, unrelated to any ADR-338 source change. Disabling EnableSourceControlManagerQueries in Directory.Build.props skips the failing git query; Nerdbank.GitVersioning computes assembly version info independently and is unaffected (verified ThisAssembly.GitCommitId is still generated correctly).
jodavis-claude
left a comment
There was a problem hiding this comment.
Verified all six exit criteria: mypy pinned in ml/requirements.txt (confirmed 2.3.0 is genuinely the current latest release via pip index versions mypy in this environment), [tool.mypy] strict config in ml/pyproject.toml (no blanket ignore_missing_imports, correctly deferring per-import handling to later tasks), scripts/validate-ml-build.sh/.cmd added and modeled closely on the existing validate-build pair (including matching executable-bit fix), scripts/validate.sh/.cmd wired in after validate-build, CLAUDE.md Quality Gates table updated, and the script passes cleanly against the package-marker-only tree (re-ran it directly: Success: no issues found in 2 source files). Also re-ran dotnet build /warnaserror clean (0 warnings/errors) to confirm the Directory.Build.props fix doesn't regress the main build, and confirmed Nerdbank.GitVersioning's ThisAssembly.GitCommitId still resolves correctly with EnableSourceControlManagerQueries disabled. One non-blocking scope note left inline. No Priority 1-4 issues found.
There was a problem hiding this comment.
This should be added to the CI workflow. (The spec said so at one point, that must have been removed.)
Work item
ADR-338 — Task 1 of the OOP ML pipeline epic (ADR-191). Wires
mypy --strictstatic analysis into theml/build so every subsequent pipeline task is written strict-clean from the start instead of needing a later cleanup pass.Changes
ml/requirements.txt— addedmypy==2.3.0(current stable release at implementation time).ml/pyproject.toml(new) —[tool.mypy]section withstrict = trueandpython_version = "3.12". No blanketignore_missing_importssuppression, so later tasks handle each untyped import (tensorflow/librosa/edge_tts) explicitly as the spec expects.ml/pipeline/__init__.pyandml/test/__init__.py(new, empty) — package markers somypy --strict pipeline testhas files to scan; without them mypy exits non-zero with "no .py[i] files".scripts/validate-ml-build.sh/.cmd(new) —cds intoml/and runsmypy --strict pipeline test, modeled on the existingvalidate-build.sh/.cmdstructure and naming convention.scripts/validate.sh/.cmd(modified) — added a call tovalidate-ml-buildbetweenvalidate-buildandvalidate-tests.CLAUDE.md(modified) — Quality Gates table: added a new row forscripts/validate-ml-build, renumbering the existing rows.Directory.Build.props(modified) — addedEnableSourceControlManagerQueries=falseto fix a build failure in this worktree checkout (SDK-pinned SourceLink task errors on theextensions.relativeworktreesgit config set by newer git versions on worktree checkouts; fixed upstream only in a later SDK line not present here). Verified Nerdbank.GitVersioning still resolves assembly version info correctly since it queries git independently of SourceLink.Design decisions
ml/pyproject.tomlminimal (strict+python_versiononly) rather than pre-adding[[tool.mypy.overrides]]fortensorflow/librosa/edge_tts— consistent with the spec's description of later tasks handling each untyped import as it's introduced..github/workflows/build-and-test.yml— exit criteria only namescripts/validate.sh/.cmdandCLAUDE.md, not CI wiring.Testing completed
scripts/validate-build.sh(dotnet build /warnaserror) — clean, 312 unit tests passing.scripts/validate-ml-build.sh(mypy --strict pipeline test) — passes cleanly against the package-marker-only tree.ml/pipeline/, confirmedmypy --strictflagged it (no-untyped-def), then removed it.