Registry / type-stubs / types-grpcio

types-grpcio

JSON →
library1.83.0.20260730pypypi✓ verified 24d ago

This library provides high-quality type stubs for the `grpcio` Python library, enabling static type checkers like MyPy to understand gRPC-related code. It's part of the `typeshed` project. The current version is 1.0.0.20260408, with releases typically following updates from the main `grpcio` library or the broader `typeshed` project, often on a monthly or bi-monthly basis.

pip install types-grpcio
INSTALL
IMPORT
SIG · TYPES-GRPCIO
T
types-grpcio
type-stubspythonv1.83.0.20260730
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.83.0.20260730 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

grpc-stubs
import grpc_stubs
import grpc-stubs

This quickstart demonstrates how `types-grpcio` enables static type checking for common `grpcio` operations, ensuring type correctness during development. It shows the basic usage of `grpc.insecure_channel` and explains how type checkers benefit from the installed stubs.

import grpc from typing import cast # To make this example runnable, you would typically have: # 1. A .proto file defining a service (e.g., helloworld.proto) # 2. Generated Python code for the service (e.g., helloworld_pb2.py, helloworld_pb2_grpc.py) # using `python -m grpc_tools.protoc ...` def demonstrate_typing(): # types-grpcio provides type hints for grpc functions and objects. # For instance, `grpc.insecure_channel` is correctly typed. channel: grpc.Channel = grpc.insecure_channel('localhost:50051') print(f"Successfully created a gRPC channel: {type(channel).__name__}") # With types-grpcio, static analysis tools like MyPy can verify # that `channel` is indeed a `grpc.Channel` object and that its methods are correct. # Example (would require generated stubs for full type checking): # from helloworld_pb2_grpc import GreeterStub # stub: GreeterStub = GreeterStub(channel) # print("Type hints for gRPC stub are available.") channel.close() if __name__ == '__main__': demonstrate_typing() # To verify types with MyPy: # 1. Ensure `grpcio`, `types-grpcio`, and `mypy` are installed: # `pip install grpcio types-grpcio mypy` # 2. Run MyPy on this file: # `mypy your_script_name.py` # MyPy should report no errors for the `grpc` types.
Debug
Known issues
gotchaRemember to install the `grpcio` runtime library itself. `types-grpcio` provides only type hints and is not a runtime dependency; your application will fail at runtime if `grpcio` is not installed.
fix
Ensure both `grpcio` and `types-grpcio` are installed: `pip install grpcio types-grpcio`.
affects: All
gotchaUsing a `types-grpcio` version that is significantly older or newer than your `grpcio` runtime library can lead to incorrect type checking results, `mypy` errors, or missed type safety improvements.
fix
Keep `types-grpcio` updated, ideally in sync with your `grpcio` installation. `types-grpcio` versions often include a date stamp (e.g., `1.0.0.20260408`) to indicate when they were generated against a specific `grpcio` version or typeshed state.
affects: All
gotchaType checking for your own gRPC generated code (from `.proto` files) requires additional configuration for `mypy`, often involving the `mypy-protobuf` plugin or `mypy`'s `--proto-path` flag. `types-grpcio` primarily covers the core `grpcio` library, not your specific service stubs.
fix
Consult the `mypy-protobuf` documentation or `mypy`'s documentation for correctly type checking custom generated gRPC code.
affects: All
Upgrade
Version history
1.83.0.20260730latest on PyPI · released Jul 30, 2026
Audit
Dependencies
grpciorequiredProvides type stubs for the `grpcio` library; it is functionally useless without `grpcio` itself installed.
Agent activity
35 hits · last 30 days
node
32
OpenAI (training)
1
Resources
types-grpcio — pip install types-grpcio · libregistry