Comments (5)
You have to generate type hints for your stubs: https://github.com/nipunn1313/mypy-protobuf
from grpc-stubs.
So the thing is that I did generate the the type hints, and they are all there for the protobufs themselves. But there are no type hints for the stubs on the client side. The version of mypy-protobuf that I'm using is 3.2.0.
from grpc-stubs.
Did you add __init__.py
files for your stubs? If not, may need to set namespace packages to True with mypy.
I may be misunderstanding you, though.
from grpc-stubs.
So what I mean is that I generate my protos with this command:
python -m grpc_tools.protoc -I <proto folder> --python_out=<output folder> --grpc_python_out=<output fuolder> --mypy_out=<output folder> <proto folder>/*.proto
When I then typecheck my project, there are no issues whatsoever with the proto-objects (e.g. I can instantiate them, assign values etc, wrong value types raise type errors etc). But when instantiating the client stub as per my code snippet above (when implementing a gRPC client), type checking produces the error no-untyped-call
, as it doesn't find any type hints for the client stub (e.g. which methods are defined on the stubs, which proto objects are expected as input / output etc).
I'm currently silencing this error (# type: ignore[no-untyped-call]
), but it would be nice to get actual type hints for it (e.g. to get code completion in IDEs etc, have general type checking on the project, ...)
from grpc-stubs.
Hmm. Maybe try adding --mypy_grpc_out
as well?
from grpc-stubs.
Related Issues (20)
- Consider using pytest-mypy-plugins HOT 13
- 1.24 updates
- Typeshed HOT 9
- Argument `grace` of Server.stop() should be Optional[float] HOT 1
- Publish new version HOT 1
- Distribution doesn't include py.typed files. HOT 2
- No stubs for `aio` HOT 9
- can mypy be optional dependency? HOT 2
- Typing of HealthServicer.set HOT 6
- Missing grpc StatusCode HOT 1
- The partial typing of the aio.pyi module causes an error HOT 4
- pypi version 1.53.0.1 HOT 1
- enable_server_reflection should allow aio server instances
- The object returned from `UnaryStreamMultiCallable` and `StreamStreamMultiCallable` should also be a `Future` HOT 2
- Wrong type hints for continuation in streaming interceptors HOT 1
- intercept_stream_stream in grpc.aio incorrectly marked as a coroutine HOT 2
- `ServerInterceptor.intercept_service` return type doesn't match continuation return type HOT 2
- Type hints for abstract base classes are missing `abc.ABC`
- `CallIterator` is missing `__next__` method
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpc-stubs.