frequenz-floss / frequenz-client-base-python

Base gRPC client
https://frequenz-floss.github.io/frequenz-client-base-python/
MIT License
0 stars 3 forks source link

Improve type-checking for `_grpchacks` #59

Closed llucax closed 5 months ago

llucax commented 5 months ago

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 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 making ChannelT bound to an AsyncContextManager[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.

llucax commented 5 months ago

Added auto-merge.

llucax commented 5 months ago

Skipping release notes as this affects an unreleased feature.

llucax commented 5 months ago

Oh, damn, I forgot about the typo in the commit message :disappointed: