-
Couldn't load subscription status.
- Fork 5
Improve BaseApiClient example
#86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The `mypy-protobuf` plugin generates a `XxxAsyncStub` class for each service, which have proper type information to be used with async. This still needs some hacks (type ignore) to make it work, but it's better than using the normal stubs and having to cast on each call. Signed-off-by: Leandro Lucarella <[email protected]>
BaseApiClientBaseApiClient example
Signed-off-by: Leandro Lucarella <[email protected]>
Pull request was converted to draft
|
Converting to draft because I'm finding issues at runtime with this approach, because the |
|
It looks like we need this accepted to make it work: Otherwise we can't use the If this doesn't get updated and we want to still use the async stub, I guess we need to take out the stub from the |
|
A quick hack is: def __init__(...) -> None:
super().__init__(
server_url,
microgrid_pb2_grpc.MicrogridStub,
connect=connect,
channel_defaults=channel_defaults,
)
self._async_stub: microgrid_pb2_grpc.MicrogridAsyncStub = self.stub # type: ignoreAnd then just use |
|
Superseded by: The improvement of the documentation to include defaults will be done in a separate PR. |
mypy-protobufplugin generates aXxxAsyncStubclass for each service, which have proper type information to be used with async. This still needs some hacks (type ignore) to make it work, but it's better than using the normal stubs and having to cast on each call.channel_defaults.