英文:
How to generate python type hints in generated grpc code
问题
PEP 兼容的类型提示是否可以自动添加到生成的源代码中,或者为 Python 和 gRPC 动态创建?具体来说,在基础教程中,在客户端部分的 feature = stub.GetFeature(point)
,我希望我的 IDE 知道并检查 point 的类型是 Point
在 *_pb2.py
中,并且 feature 的类型是具有属性 location: Point
的 Feature
。谢谢。
英文:
Can PEP compliant type hints be automatically added to generated source code, or dynamically created, for python and gRPC? Specifically in the basics tutorial in the client section for feature = stub.GetFeature(point)
I would like my IDE to know and check that point is type Point
in the *_pb2.py
and feature is type Feature
with an attribute location: Point
. Thank you.
答案1
得分: 1
Type hints aren't yet (!?) available for Python gRPC, see Issue 29041
You can generate type hints for the Protobuf messages only using the --pyi_out=${PWD}
flag when running protoc
directly or indirectly with python3 -m grpc.tools.protoc
英文:
Type hints aren't yet (!?) available for Python gRPC, see Issue 29041
You can generate type hints for the Protobuf messages only using the --pyi_out=${PWD}
flag when running protoc
directly or indirectly with python3 -m grpc.tools.protoc
答案2
得分: 1
对于生成的protobuf文件(*_pb2.py
),我们有一份正在审查中的PR,以添加pyi文件。至于gRPC Python的一般情况,我目前正在处理它,预计将在本季度末完成。
英文:
For protubuf generated files (*_pb2.py
), we have a PR in review to add pyi files. And for gRPC Python in general, I'm currently working on it and it should be finished by end of this quarter.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论