-
Notifications
You must be signed in to change notification settings - Fork 3
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
Improve BaseApiClient
example
#86
base: v0.x.x
Are you sure you want to change the base?
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]>
BaseApiClient
BaseApiClient
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: ignore And then just use |
mypy-protobuf
plugin generates aXxxAsyncStub
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.channel_defaults
.