-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Description
Hi,
Thank you for this wonderful project. I'm integrating mypy with a codebase that uses protobufs and feel that this will be quite helpful in doing so!
I'm able to generate the *.pyi
type stub files along with the other definitions by invoking the following command:
$ python -m grpc_tools.protoc -I=github.com/gogo/protobuf/gogoproto -I=. \
--python_out=generated/python \
--grpc_python_out=generated/python \
--mypy_out=generated/python
The generated *.pyi
files look correct, however when I try to run mypy
over modules that import these definitions, I receive error messages like the following (names/line #s scrubbed):
generated/python/foo_pb2.pyi:123: error: Function "Foo" is not valid as a type
generated/python/foo_pb2.pyi:123: note: Perhaps you need "Callable[...]" or a callback protocol?
Inside of foo_pb2.py
, Foo
is defined like follows:
Foo = _reflection.GeneratedProtocolMessageType('Foo', (_message.Message,), {
'DESCRIPTOR' : _FOO,
'__module__' : 'path.to.foo'
# @@protoc_insertion_point(class_scope:Foo)
})
_sym_db.RegisterMessage(Foo)
Is there something obvious I'm doing wrong? I'm using the following versions for my dependencies:
- mypy 0.761
- mypy-protobuf 1.18
- Python 3.6.5
- python-protobuf 3.11.3
$ python -m grpc_tools.protoc --version
libprotoc 3.8.0
Thanks!
vincehoward, jahan-addison and LiquidLemon
Metadata
Metadata
Assignees
Labels
No labels