NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1450 most downloaded on PyPI
Generate mypy stub files from protobuf specs
Last release 5 months ago
28 Apr 2026
Release timing varies
gaps range from 3 weeks to 1.6 years
Most releases are documented
notes for 33 of 46 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
46 releases · first in 2018
Signed-off-by: Aidan Jensen aidan.jensen@robust.ai Co-authored-by: Aidan Jensen aidan.jensen@robust.ai
Signed-off-by: Aidan Jensen aidan.jensen@robust.ai
Co-authored-by: Aidan Jensen aidan.jensen@robust.ai
Breaking change because the import paths change so if people were manipulating input paths, theyu are now different.
Signed-off-by: Aidan Jensen aidandj.github@gmail.com
One column per quarter.
builtins.property to handle conflicts with fields named propertycollections, builtins, etc.
from test.a.b import c as _c_{count}
from test.a.x import c as _c_1Signed-off-by: Aidan Jensen aidandj.github@gmail.com
Signed-off-by: Aidan Jensen aidandj.github@gmail.com
Signed-off-by: Aidan Jensen aidandj.github@gmail.com
Signed-off-by: Aidan Jensen aidandj.github@gmail.com
py_generic_services as it was removed from the protobuf compiler starting in version 6.30
generate_concrete_servicer_stubs option to generate concrete instead of abstract servicer stubssync_only/async_only options to generate only sync or async version of GRPC stubs_HasFieldArgType and _ClearFieldArgType aliases to allow for typing field manipulation functions_WhichOneofArgType_<oneof_name> and _WhichOneofReturnType_<oneof_name> type aliases__new__ overloads for async stubs instead of TypeVar based __init__ overloads.
Message deprecations are supported
TypeAlias.global___ to Global___ to respect
Y042 naming convention.Bump to 3.6.0
Bump to 3.6.0 (#584)
Bump to 3.5.0
Bump to 3.5.0 (#541)
Bump to 3.4.0
Bump to 3.4.0 (#440)
Bump to release 3.3.0
Bump to release 3.3.0 (#401)
typing over typing_extensions on new enough python versionsX | None rather than Optional[X]Bump to release 3.2.0
Bump to release 3.2.0 (#343)
... in generated files.*_FIELD_NUMBER for extensionsrequest -> request_iterator)Bump to release 3.1.0
Bump to release 3.1.0 (#323)
EnumTypeWrapper.V to EnumTypeWrapper.ValueType per https://github.com/protocolbuffers/protobuf/pull/8182.
Will allow for unquoted annotations starting with protobuf 3.20.0. .V will continue to work for the foreseeable
future for backward compatibility.selfDrop support for targeting python 2.7
"" rather than u"")Switch from setup.py to pyproject.toml and setup.cfg per https://packaging.python.org/tutorials/packaging-projects/
_grpc_pb2.pyi stubs. grpc stubs themselves don't use relative imports, nor __init__.py files""" docstring style comments in generated code rather than # style so it shows up in IDEs.None) with prefix _r_ rather than __ - since __ is considered private.Make install_requires requirements for grpcio-tools and types-protobuf use >=
install_requires requirements for grpcio-tools and types-protobuf use >=Propagate comments from .proto files to .pyi files
V into a separate class.protoc_gen_mypy.bat as the entry-points method creates protoc-gen-mypy.exe. Add test confirming.Fix #244 - support extensions defined at module scope with proper types, matching extensions defined within Messages. See `_ExtensionDict`
_ExtensionDictextend google.protobuf.MessageOptions {
string test_message_option = 51234;
}
# Used to generate
test_message_option: google.protobuf.descriptor.FieldDescriptor = ...
# Now generates
test_message_option: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.MessageOptions, typing.Text] = ...
Fix repeated extensions as well - to generate RepeatedScalarFieldContainer and RepeatedCompositeFieldContainer
Use latest python versions in tests (3.6.14 3.7.11 3.8.11 3.9.6)
message M {
message None {}
None none = 1;
}
protoc-gen-mypy -V and protoc-gen-mypy --version to print version numberOptional[Literal[...]] instead of Literal[...] from WhichOneof to support
cases in which none of the fields of the WhichOneof are set. See the following example.def hello(name: str) -> None: ...
n = proto.WhichOneof("name")
hello(n) # Will now result in a mypy error.
assert n is not None
hello(n) # Should work ok
# type: ignore for enum generated stubs to avoid circular dependency described in #214. Bandaid solution.Organized generated enum code to prevent definition ordering issues in Pyright-based linters
grpcio stubs to use the MultiCallable API (see here) . This requires using the grpc-stubs typings for grpcio. This change should allow calling stub methods with common parameters (timeout, metadata, etc.) as well as calling methods on the MultiCallable object (e.g. my_stub.MyRpcMethod.future()).Add support for _FIELD_NUMBER generated fields on messages as specified in the spec
_FIELD_NUMBER generated fields on messages as specified in the specFix CI caching across version updates.
import publicFix bug where module level DESCRIPTOR: FileDescriptor was not being generated for files w public imports
DESCRIPTOR: FileDescriptor was not being generated for files w public importsFix crash when a import public reexport when dependent proto file is not listed on command line for generation
Deprecate and delete the go/ implementation
Non Backward Compatible Changes
MyEnum.V rather than MyEnumValue for import ergonomics,
allowing the caller to import MyEnum rather than conditionally importing MyEnumValueNone as argument for primitive fields of constructors in proto3.
Provided relax_strict_optional_primitives flag to relax this strictness if you prefer.New Features
grpcio stubs generationmypy_protobuf.py to be run directly as a scriptwell_known_typesself - by renaming the constructor's self to self_mypy/mypy.proto to mypy_protobuf/extensions.protomypy_protobuf.casttype, mypy_protobuf.keytype, and mypy_protobuf.valuetypeimport public proto imports - by reexporting in generated codeOutput Format
global___ to avoid conflict w/ fields of same name [previously was mangling inner messages as well]readable_stubs parameter for mangle-free output code w/o fully-qualified references to message.
(in many cases this is good enough and easier to read)arg: Optional[type] = ... instead of arg: Optional[type] = NoneInternal Improvements
__future__ import in mypy_protobuf_lib.pyBump required mypy version to 0.800
.pyi file header to cite mypy-protobufgenerated directorytype___ prefixed alias for inner enum type wrappersMessage.Extensions mapping to support better type inference for proto2 message extensionsMessage.HasExtension and Message.ClearExtensionget_or_createmessage Message {
map<int32, OuterMessage3> map_message = 17
}
and
message.map_message.get_or_create(0)
Before (1.23)
main.py:4: error: "MutableMapping[str, Nested]" has no attribute "get_or_create" [attr-defined]
After (1.24) - there is no error
Inherit FromString from superclass Message - rather than re-generating here. Fixes bug in python2 usage google/protobuf/type_pb2.pyi:92: error: Argume
google/protobuf/type_pb2.pyi:92: error: Argument 1 of "FromString" is incompatible with supertype "Message"; supertype defines the argument type as "ByteString" [override]Update tested/required mypy version to 0.780 (picks up new typeshed annotations). Includes improved typing/error messages on Message.
Before (mypy < 0.780):
test_negative/negative.py:26: error: Argument 1 to "CopyFrom" of "Message" has incompatible type "str"; expected "Message"
After (mypy >= 0.780:
test_negative/negative.py:26: error: Argument 1 to "CopyFrom" of "Message" has incompatible type "str"; expected "Simple1"
ProtoEnum.Value('first') should work either way.Generated Before (in 1.21)
class ProtoEnum(object):
@classmethod
def Value(cls, name: str) -> ProtoEnumValue
Generated After (in 1.22)
ProtoEnum: _ProtoEnum
class _ProtoEnum(google.protobuf.EnumTypeWrapper):
def Value(self, name: str) -> ProtoEnumValue
Update mangling from global__ to message__
global__ to message__Example:
enum ProtoEnum {
FIRST = 1;
SECOND = 2;
}
mesage ProtoMsg {
ProtoEnum enum = 1;
}
Generated Before (in 1.20):
class ProtoEnum(object):
@classmethod
def Value(cls, name: str) -> ProtoEnum
class ProtoMsg(Message):
def __init__(self, enum: ProtoEnum) -> None
Generated After (in 1.21):
ProtoEnumValue = NewType('ProtoEnumValue', int)
class ProtoEnum(object):
@classmethod
def Value(cls, name: str) -> ProtoEnumValue
class ProtoMsg(Message):
def __init__(self, enum: ProtoEnumValue) -> None
Migration Guide (with example calling code)
Before (with 1.20)
from msg_pb2 import ProtoEnum, ProtoMsg
def make_proto_msg(enum: ProtoEnum) -> ProtoMsg:
return ProtoMsg(enum)
make_proto_msg(ProtoMsg.FIRST)
After (with 1.21)
from msg_pb2 import ProtoEnum, ProtoMsg
def make_proto_msg(enum: 'msg_pb2.ProtoEnumValue') -> ProtoMsg:
return ProtoMsg(enum)
make_proto_msg(ProtoMsg.FIRST)
Fix message/field name aliasing when field name matches a message/enum name
Allow omitting required proto2 fields from constructor parameters
Use entry_points:console_scripts to support long paths to the python interpreter
entry_points:console_scripts to support long paths to the python interpreterUpdate to newer mypy version - including minor changes to typeshed
Absolute path to necessary python
Add class to set of python keywords
class to set of python keywords- Add Message.DESCRIPTOR
Message.DESCRIPTORNothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →