Static type checking in CI via mypy + baseline ratchet (WIP) - #248
Open
naumitch wants to merge 3 commits into
Open
Static type checking in CI via mypy + baseline ratchet (WIP)#248naumitch wants to merge 3 commits into
naumitch wants to merge 3 commits into
Conversation
Introduce static type checking that is green from day one and never blocks CI on pre-existing debt. - Add mypy + mypy-baseline + type stubs to the dev extra; regenerate uv.lock. - Add [tool.mypy] (pragmatic floor) and [tool.mypy-baseline] config. - Commit .mypy-baseline.txt (471 pre-existing errors) so CI fails only on NEW type errors; the baseline is the burndown ledger and can only shrink. - Ship a py.typed marker so consumers (e.g. Megatron-LM) get our annotations. - Add justfile recipes (typecheck / typecheck-baseline / typecheck-progress) and a typecheck.yml workflow mirroring ruff.yml. - Document the strategy and contributor workflow in docs/source/internals/type_checking.md (wired into the toctree) and link it from CONTRIBUTING.md. No runtime code changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Nicholas Autio Mitchell <naumitch@nvidia.com>
…ated Demonstrate the baseline ratchet end-to-end: - Graduate 10 fully-strict-clean modules (incl. the public loader.py and source_info.py) to per-module strict via [[tool.mypy.overrides]], locking them so they cannot regress to loose typing. - Fix 19 of 20 var-annotated errors with precise variable annotations across 12 modules (the 20th, in lint.py, is left in the baseline because annotating it perturbs unrelated overload inference). - Materialize a Sequence into a list in MetadatasetV2.prepare() so 'files' is consistently list[EPath] (behaviour-preserving). Baseline shrinks 471 -> 450 errors (63 -> 60 files). Gate stays green. Full unittest suite passes (138 tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Nicholas Autio Mitchell <naumitch@nvidia.com>
Make the type-checking doc front-load what contributors actually need: - New 'TL;DR - what this means for you': the no-negative-impact guarantees in plain language (PRs are not blocked by old errors, you never fix code you did not touch, no runtime risk, the backlog can only shrink). - New 'Using it day to day': the simple loop, a green/red gate table, and how to lock a finished file in. Replaces the terse bottom cheat-sheet. - Relabel the metrics as the starting baseline (live count via just typecheck-progress); fix stale numbers and a leftover 'pipefail' reference that contradicted the corrected gate recipe. Docs build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Nicholas Autio Mitchell <naumitch@nvidia.com>
naumitch
marked this pull request as ready for review
June 24, 2026 22:17
naumitch
force-pushed
the
nicholas/static-type-checks-in-ci
branch
from
June 25, 2026 15:25
dbf2cb3 to
9b2121c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP — foundation + first burndown slice. Strategy & contributor guide:
docs/source/internals/type_checking.md..mypy-baseline.txtratchet — green from day one; never blocks PRs on the ~450 pre-existing errors.py.typedmarker so consumers (e.g. Megatron-LM) receive Energon's type annotations.[tool.mypy]pragmatic floor;mypy/mypy-baseline/types-*in thedevextra (uv.lock regenerated);just typecheck/typecheck-baseline/typecheck-progressrecipes;typecheck.ymlmirroringruff.yml.var-annotatederrors → baseline 471 → 450. No runtime change beyond one behaviour-preservinglist()materialization.🤖 Generated with Claude Code