Skip to content

fix(ci): align pre-commit mypy with CI — install mypy in uv dev group#427

Merged
bokelley merged 2 commits into
mainfrom
bokelley/dx-2-mypy-divergence
May 3, 2026
Merged

fix(ci): align pre-commit mypy with CI — install mypy in uv dev group#427
bokelley merged 2 commits into
mainfrom
bokelley/dx-2-mypy-divergence

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented May 3, 2026

Summary

  • Pre-commit's uv run mypy reported 96 errors that didn't reproduce in CI. Root cause: mypy was only in [project.optional-dependencies].dev, which uv run doesn't install by default — so uv run mypy fell through to a system mypy on $PATH (e.g. homebrew) that couldn't see the project's types-protobuf / a2a-sdk stubs.
  • Adding mypy>=1.20.0 to [dependency-groups].dev makes uv sync install mypy into the project venv, so uv run mypy resolves to the in-venv binary that sees the project's stubs.
  • CI is untouched: it uses pip install -e \".[dev]\" and [dependency-groups] is uv-only (PEP 735), which pip ignores.

Before / after

  • Before: uv run pre-commit run mypy --all-files exits 1 with 96 errors in 5 files (client.py, protocols/a2a.py, server/a2a_server.py, server/translate.py, webhooks.py) — all about a2a/protobuf attrs (Role.ROLE_USER, TaskState.TASK_STATE_*, Part.WhichOneof, Message.HasField, google.protobuf.json_format).
  • After: uv run pre-commit run mypy --all-files exits 0.

Test plan

  • Reproduce: cd /tmp/adcp-mypy-fix && uv run mypy src/adcp/ → 96 errors.
  • Apply fix.
  • Re-run: uv run mypy src/adcp/Success: no issues found in 747 source files.
  • Re-run pre-commit hook: uv run pre-commit run mypy --all-filesPassed, exit 0.
  • Confirm CI mypy path unaffected (pip install -e \".[dev]\" ignores [dependency-groups]).

bokelley and others added 2 commits May 2, 2026 22:45
The pre-commit hook ``entry: uv run mypy`` was reporting 96 type errors
that didn't reproduce in CI's mypy run on the same source. Root cause:
``mypy`` was only listed in ``[project.optional-dependencies].dev``,
which ``uv run`` doesn't install by default. With no ``mypy`` in the
project venv, ``uv run mypy`` fell through to whatever ``mypy`` was on
``$PATH`` (e.g. a homebrew install), which uses its own Python and
can't see the project's ``types-protobuf`` / ``a2a-sdk`` stubs.

Adding ``mypy>=1.20.0`` to ``[dependency-groups].dev`` makes ``uv sync``
install mypy into the project venv, so ``uv run mypy`` resolves to the
in-venv binary that sees the project's stubs.

Before: ``uv run pre-commit run mypy --all-files`` exits 1 with 96
errors. After: exits 0. CI's ``pip install -e ".[dev]"`` path is
unchanged — ``[dependency-groups]`` is uv-only (PEP 735) and pip
ignores it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code reviewer flagged that pyproject.toml had two diverging mypy
specifiers: 'mypy>=1.0.0' in [project.optional-dependencies].dev
(used by CI's pip install) and 'mypy>=1.20.0' in [dependency-groups].dev
(used by uv run pre-commit). They'd drift on the next mypy release.

Bump the optional-deps to 'mypy>=1.20.0,<1.21' so CI and pre-commit
both use the same locked range. Upper bound prevents the next mypy
minor release from silently re-introducing the divergence the original
PR is fixing — mypy is famously prone to false-positive churn between
minor releases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit d3d8f7b into main May 3, 2026
11 of 12 checks passed
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