Skip to content

Replace hand-written ty machinery with the official ty-pre-commit hook#133

Open
hmgaudecker wants to merge 1 commit into
mainfrom
official-ty-pre-commit-hook
Open

Replace hand-written ty machinery with the official ty-pre-commit hook#133
hmgaudecker wants to merge 1 commit into
mainfrom
official-ty-pre-commit-hook

Conversation

@hmgaudecker

Copy link
Copy Markdown
Contributor

Summary

ty now runs only as pre-commit hooks, under both backends, replacing the dedicated pixi type-checking/type-checking-jax features, environments, and tasks (pixi run ty / pixi run ty-jax no longer exist).

  • numpy run: the official astral-sh/ty-pre-commit hook with args: [--no-project]. uv creates no .venv/uv.lock in this pixi-managed repo and resolves no dependencies itself (its default mode fails on the pygraphviz source build anyway); ty resolves third-party imports from the pixi py314 environment via tool.ty.environment.python in pyproject.toml.
  • jax run: a minimal local hook running the same pinned ty with --python .pixi/envs/py314-jax. It inherits the entire tool.ty configuration — same rules, only the environment differs. Verified that jax genuinely resolves in this run (passes even with jax dropped from analysis.allowed-unresolved-imports).

The jax variant cannot use the official hook today: uv check forwards nothing to ty (no --python, no -c, no trailing args), and ty rejects conda-style envs handed over via VIRTUAL_ENV (no pyvenv.cfg). The local hook's ty==0.0.48 pin carries a comment to keep it in sync with the hook rev, since prek auto-update bumps only the rev.

Other changes

  • The run-ty CI job installs py314/py314-jax and runs the hooks via prek, so the pre-commit config is the single definition of how ty runs everywhere.
  • Both ty hooks are skipped on pre-commit.ci (no network at hook runtime, no pixi environments).
  • The existing test environments provide everything ty needs (including type stubs), so the dedicated type-checking environments are gone — including their ~1800 lines in pixi.lock. pixi 0.70.2 does not prune removed environments from the lock; the stale blocks and orphaned ty package entries were removed manually and the result validated with pixi lock.
  • AGENTS.md: verification is now two steps; prek run --all-files covers type checking under both backends.

Test plan

  • pixi run -e py314-jax prek run --all-files — all hooks pass, including both ty variants
  • pixi run --locked -e py314 prek run ty --all-files and ... ty-jax --all-files (exact CI commands)
  • pixi run --locked -e py314-jax tests -n 7 — 1119 passed, 42 skipped
  • pixi lock — lock file validates after pruning

🤖 Generated with Claude Code

ty now runs only as pre-commit hooks, under both backends:

- numpy: official astral-sh/ty-pre-commit hook with `--no-project`, so uv
  creates no `.venv`/`uv.lock`; ty resolves third-party imports from the
  pixi `py314` environment via `tool.ty.environment.python`.
- jax: a minimal local hook running the same pinned ty with
  `--python .pixi/envs/py314-jax`, inheriting the full `tool.ty`
  configuration. A local hook is needed because `uv check` does not
  forward any flags to ty.

The dedicated `type-checking`/`type-checking-jax` pixi features,
environments, and tasks are removed; the existing test environments
provide everything ty needs. The `run-ty` CI job runs the hooks via
prek. Both hooks are skipped on pre-commit.ci (no network at hook
runtime, no pixi environments).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant