Repository navigation
Give Codec type variables defaults - #345
Merged
Merged
Conversation
Generated *_connect.py files annotate their codecs/codec parameters with a bare Codec, which mypy --strict reports as a missing type argument ([type-arg]) in every generated service file. Give T_contra and U a PEP 696 default of Any via typing_extensions.TypeVar, so a bare Codec means Codec[Any, Any] and generated code type-checks without changing the generator or its output. typing_extensions was already in the runtime dependency tree through protobuf-py and pyqwest; declare it directly with the same >=4.13.0 floor protobuf-py uses. This mirrors bufbuild/protobuf-py#79. Fixes #341 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: i2y <6240399+i2y@users.noreply.github.com>
i2y
marked this pull request as ready for review
September 22, 2026 15:20
anuraaga
approved these changes
Sep 24, 2026
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.
Generated *_connect.py files annotate their codecs/codec parameters with a bare Codec, which mypy --strict reports as a missing type argument ([type-arg]) in every generated service file.
Giving T_contra and U a PEP 696 default of Any, via typing_extensions.TypeVar, is enough on its own. A bare Codec then means Codec[Any, Any], and the generated code type-checks as it stands, with no change to the generator or its output. typing_extensions is now a direct dependency, with the same >=4.13.0 floor protobuf-py uses; it was already in the runtime tree through protobuf-py and pyqwest, so an install gains nothing new.
This mirrors bufbuild/protobuf-py#79.
Fixes #341