chore(pre-commit): run mypy in the uv venv via a local hook#181
Conversation
) mirrors-mypy built a separate isolated env and reinstalled the full dependency set into it (sentence-transformers pulls torch), making cold runs take 20+ min on WSL and requiring a hand-maintained additional_dependencies list that drifts from pyproject.toml. Replace it with a repo: local / language: system hook that runs `uv run mypy ontokit/` — the same command and scope as CI — reusing the already-installed project venv. No env build, no parallel dependency list; strictness and target Python come from [tool.mypy] in pyproject.toml. Measured: cold run 20+ min -> ~1m44 (one-time mypy cache build), warm run ~0.8s. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changesmypy pre-commit hook replacement
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
What
Replaces the
mirrors-mypypre-commit hook with arepo: local/language: systemhook that runsuv run mypy ontokit/— the same command and scope as CI (release.yml) — reusing the uv-managed project venv.Why
mirrors-mypybuilt a separate isolated env and reinstalled the full dependency set into it —sentence-transformerspulls torch — so a cold run took 20+ min on WSL (a routinegit commitlooked hung). It also required a hand-maintainedadditional_dependencieslist that drifts frompyproject.toml(it already carried a bespokenumpy<2.5mypy pin).This hook reuses the already-installed venv: no env build, no parallel dependency list, single source of truth. Strictness and target Python come from
[tool.mypy]inpyproject.toml, matching CI exactly.Measured
Notes / decisions
ontokit/only — nottests/. The old hook type-checked all staged Python (incl. tests), which is what surfaced Slow pre-commit mypy hook: rebuilds a heavyweight isolated env (torch via sentence-transformers) #179. If we want tests covered, that should be a deliberate change to both this hook and CI.uvlocally (already the project's standard setup).Closes #179
Summary by CodeRabbit
Note: This release contains internal development infrastructure updates with no end-user facing changes.