-
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 type-checking for _grpchacks
#59
Conversation
The `ChannelT` `TypeVar` was causing a lot of issues because the types in it would change dynamically depending on which grpc library is installed. This transpired to user code wanting to subclass `BaseApiClient` which is less than ideal (hacks should be kept internal). This commit improves this by adding a function to create a channel, which also avoids the need to create a lot of stub `grpcio` functions, and making `ChannelT` bound to an `AsyncContextManager[Any]` instead of the two specific channel classes we use. This interface is enought for the functionality we need from channels. This way the hacks don't leak to the type system, which was the main issue. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Added auto-merge. |
Skipping release notes as this affects an unreleased feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only have a question to check for but it might be not entirely related to the current changes. There is a typo in the commit message in case you'd like to fix it in enought
.
LGTM, though I'll be waiting for your answer to approve it
49aee99
Oh, damn, I forgot about the typo in the commit message 😞 |
The
ChannelT
TypeVar
was causing a lot of issues because the types in it would change dynamically depending on which grpc library is installed. This transpired to user code wanting to subclassBaseApiClient
which is less than ideal (hacks should be kept internal).This PR improves this by adding a function to create a channel, which also avoids the need to create a lot of stub
grpcio
functions, and makingChannelT
bound to anAsyncContextManager[Any]
instead of the two specific channel classes we use. This interface is enough for the functionality we need from channels.This way the hacks don't leak to the type system, which was the main issue.