feat(ci): add mypy CI job, upgrade mypy 1.14→2.3, align to Python 3.11 - #297
feat(ci): add mypy CI job, upgrade mypy 1.14→2.3, align to Python 3.11#297BenjSz wants to merge 6 commits into
Conversation
Signed-off-by: Benjamin Sznajder <benjams@il.ibm.com>
|
Thanks for fixing this — bumping mypy to 2.3.0 is the right root-cause fix. I'd independently started patching the same thing on One thing worth a look before merge — Setting it to the highest supported version means mypy accepts syntax that fails at runtime on the lowest. Concretely: So if someone later adds a PEP 695 Normally the fix is I couldn't test whether mypy 2.3.0 handles that combination, since I'd have to upgrade my venv off the lockfile to try it — could you check Either way, not blocking — Two other notes:
Worth knowing for context: the lint job sets |
Signed-off-by: Benjamin Sznajder <benjams@il.ibm.com>
239d5ea to
de8cf85
Compare
…pters into benjams/mypi_checking
The check_uv_lock hook previously failed on any staged pyproject.toml whose uv.lock wasn't also staged, even when the pyproject edit was purely tool config ([tool.mypy], [tool.ruff], …) that uv.lock does not track. Defer to `uv lock --check` — the authoritative signal — and only fail when the lockfile is genuinely out-of-date. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Benjamin Sznajder <benjams@il.ibm.com>
Introduces a dedicated mypy job in test_pull_request.yaml so type checking runs on every push/PR (the local pre-commit mypy hook already exists, but CI previously skipped it because torch/transformers weren't installed in the lint job). The new job installs those stubs and runs mypy on its own runner, and is wired into the run-spyre-unit-tests gate so its result blocks merge. Pin both the tool ([tool.mypy].python_version) and the CI job to 3.11 — the same interpreter every runtime job and the Spyre pod use — so mypy analyzes the code as it will actually run, rather than as some hypothetical future 3.13. Also add an ignore_missing_imports override for sentence_transformers, matching the existing sympy/deepspec pattern: it's a real runtime dep but not installed in this cheap mypy env, and it ships no py.typed marker so installing wouldn't help anyway. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Benjamin Sznajder <benjams@il.ibm.com>
❌ merge-queue-integration: failure |
Summary
mypyCI job intest_pull_request.yaml. The pre-commitmypyhook has always existed for local dev, but CI'spre-commitlint job skips it (SKIP: mypy) because torch/transformers aren't installed there. The new job installs those stubs on its own runner and is wired into therun-spyre-unit-testsgate so a mypy failure blocks merge.1.14to2.3in thedevoptional-dependency group. Enables PEP 695 syntax handling and matches what the ecosystem's numpy/torch stubs now assume.[tool.mypy].python_versionand the CI job'spython-version). Every runtime job in the repo — Spyre pod,test_daily,push-to-clickhouse, the whole_test_matrixfleet — uses 3.11. Pinning mypy to3.13(as the earlier iteration of this PR did) would let it green-light 3.13-only syntax or stubs that then fail to import on the pod.explicit_package_bases = trueso mypy handles thehf_adapters/package layout without complaint.ignore_missing_importsoverrides fordeepspec.*(optional private DSpark dep) andsentence_transformers.*(real runtime dep, but the mypy job stays lean by not installing it — and the package ships nopy.typedmarker so installing it wouldn't help). Follows the existingsympy.*precedent.scripts/check_uv_lock.shto defer touv lock --checkinstead of blindly requiring a stageduv.lockwheneverpyproject.tomlis staged. The naive rule fires on tool-only edits ([tool.mypy],[tool.ruff], …) thatuv.lockdoesn't track, forcing a spurious lock touch. The hook now only fails when the lockfile is genuinely stale.Test plan
mypyCI job runs on this PR and reportsSuccess: no issues found in 35 source files.python3.11 -m venv /tmp/mypy311 && /tmp/mypy311/bin/pip install --quiet torch transformers 'mypy>=2.3.0,<3' && /tmp/mypy311/bin/mypy --config-file=pyproject.toml— passes.run-spyre-unit-testsfan-in gate correctly requiresmypyto have passed (test by re-running with a deliberate type error in a scratch commit, then reverting).scripts/check_uv_lock.shpasses on a tool-onlypyproject.tomledit (already verified: this PR's own[tool.mypy]edits pass the hook).[project].dependenciesentry, don't stageuv.lock, verify the hook fails.🤖 Generated with Claude Code