mypy-protobuf
Generate mypy stub files from protobuf specs
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem—enabling static type checking on protobuf code where the built-in pyi generator falls short. Install it if you use protobuf in Python and want mypy or pyright to catch type errors in your message handling and gRPC calls. Verify that your protoc and protobuf versions match the required minimums (>= 32.0) before installing.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires protoc >= 32.0 installed and on PATH, and python-protobuf >= 6.32 matching your protoc release.
- Plugin runs on Python >= 3.9.
- Low friction: pure Python wheel with only two runtime dependencies (protobuf and types-protobuf).
License · maintenance · safety
Apache License 2.0 (permissive) — Apache License 2.0 is permissive; you can use this package in commercial and private projects with minimal restrictions, provided you include a copy of the license and note any modifications.
last release 2026-04-28 (108 days) · last repo commit 2026-04-28 · 708 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 9,374,790 downloads/mo, #1,539 on PyPI
Alternatives
Verify before relying
pip install mypy-protobuf
protoc --python_out=output/location --mypy_out=output/location your_file.proto- Whether the generated stubs work correctly with mypy >= v1.14.0 or pyright >= 1.1.383 in your specific codebase.
- Compatibility with grpc code generation (requires grpcio >= 1.70, grpcio-tools >= 1.70, types-grpcio >= 1.0.0.20251009).
What it is and what it does
mypy-protobuf is a protoc plugin that generates mypy-compatible stub files from .proto definitions. Instead of relying on the protobuf compiler's built-in pyi generator, it produces stubs with more precise type information—including correctly typed HasField, WhichOneof, and ClearField methods; gRPC service and client stubs; and field presence awareness. It also preserves comments from .proto files as docstrings and marks deprecated items with @warnings.deprecated.
The plugin installs as a protoc-gen-mypy executable that integrates into the protoc build pipeline. You run it alongside the standard Python code generator, and it outputs .pyi files that type checkers like mypy and pyright can use to validate code that imports and uses the generated protobuf messages. It requires protoc >= 32.0, python-protobuf >= 6.32, and Python >= 3.9 to run; downstream type checking also needs mypy >= v1.14.0 or pyright >= 1.1.383.
Use it for
- Add static type checking to a Python project that uses protobuf messages, catching type errors at development time.
- Generate gRPC service stubs with full type annotations for both server and client code.
- Preserve proto file documentation as docstrings in generated stubs so IDEs and type checkers display help text.
- Enforce field presence constraints in constructors and HasField calls by generating precise union and literal types.
- Migrate a large protobuf codebase from untyped to typed Python incrementally using stub-based type checking.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem—enabling static type checking on protobuf code where the built-in pyi generator falls short. Install it if you use protobuf in Python and want mypy or pyright to catch type errors in your message handling and gRPC calls. Verify that your protoc and protobuf versions match the required minimums (>= 32.0) before installing.
Install
mypy-protobuf on PyPI
Before you install
Low friction: pure Python wheel with only two runtime dependencies (protobuf and types-protobuf). Actively maintained with a recent release; last commit 2026-04-28. Requires protoc >= 32.0 and Python >= 3.9 to run the plugin itself.
Requires protoc >= 32.0 installed and on PATH, and python-protobuf >= 6.32 matching your protoc release. Plugin runs on Python >= 3.9.
License in practice
Apache License 2.0 is permissive; you can use this package in commercial and private projects with minimal restrictions, provided you include a copy of the license and note any modifications.
Quickstart
pip install mypy-protobuf
protoc --python_out=output/location --mypy_out=output/location your_file.proto
Verify before relying
- Whether the generated stubs work correctly with mypy >= v1.14.0 or pyright >= 1.1.383 in your specific codebase.
- Compatibility with grpc code generation (requires grpcio >= 1.70, grpcio-tools >= 1.70, types-grpcio >= 1.0.0.20251009).
Package facts
| License | Apache License 2.0 permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesprotobuftypes-protobuf |
| Maintenance | Actively maintained 108 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,374,790 / month, #1,539 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: mypy_protobuf-5.1.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “mypy protobuf stubs”
- mypy-protobufGenerates mypy-compatible stub files (.pyi) from protobuf…
- types-protobufProvides type stubs for the protobuf package, enabling static type…
- googleapis-common-protos-stubsProvides type stubs for googleapis-common-protos, enabling static…
Give your agent the search over MCP, or paste the wish link into any chat.
More Build Tools packages
Provides reusable utilities for Python packaging interoperability, including version handling, specifiers, markers, requirements, tags, and metadata parsing according to standards like PEP 440 and PEP 425.
Wraps any iterable to display a real-time progress bar in the terminal or Jupyter notebook, showing iteration count, elapsed time, and estimated time remaining.
pip is the standard installer for Python packages, enabling you to download and install packages from the Python Package Index and other indexes into your Python environment.
Hatchling is a standards-compliant Python build backend that handles packaging, metadata, and distribution of Python projects when configured in a project's pyproject.toml file.
Generates Python gRPC service stubs and message classes from Protocol Buffer definitions, enabling developers to build gRPC clients and servers.
pre-commit is a framework for installing and running git hooks written in any language before commits are made, automating code quality and validation checks across multi-language projects.
Install it if your team needs consistent, automated validation at commit time.
See also protobuf_to_pydantic · types-protobuf · googleapis-common-protos-stubs · hatch-protobuf · pylint-protobuf · types-grpcio · types-grpcio-health-checking · types-caldav · types-typed-ast