fix(ci): align pre-commit mypy with CI — install mypy in uv dev group#427
Merged
Conversation
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>
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.
Summary
uv run mypyreported 96 errors that didn't reproduce in CI. Root cause:mypywas only in[project.optional-dependencies].dev, whichuv rundoesn't install by default — souv run mypyfell through to a systemmypyon$PATH(e.g. homebrew) that couldn't see the project'stypes-protobuf/a2a-sdkstubs.mypy>=1.20.0to[dependency-groups].devmakesuv syncinstall mypy into the project venv, souv run mypyresolves to the in-venv binary that sees the project's stubs.pip install -e \".[dev]\"and[dependency-groups]is uv-only (PEP 735), which pip ignores.Before / after
uv run pre-commit run mypy --all-filesexits 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).uv run pre-commit run mypy --all-filesexits 0.Test plan
cd /tmp/adcp-mypy-fix && uv run mypy src/adcp/→ 96 errors.uv run mypy src/adcp/→Success: no issues found in 747 source files.uv run pre-commit run mypy --all-files→Passed, exit 0.pip install -e \".[dev]\"ignores[dependency-groups]).