Add grpc_stubs config option to control stub generation#486
Add grpc_stubs config option to control stub generation#486Marenz wants to merge 1 commit intofrequenz-floss:v0.x.xfrom
Conversation
Add a new 'grpc_stubs' configuration option that allows users to choose which gRPC stubs to generate: - sync_and_async: Generate both sync and async stubs (default) - sync_only: Generate only synchronous stubs - async_only: Generate only asynchronous stubs This uses the new only_sync/only_async flags in mypy-protobuf >= 3.8.0. Fixes: frequenz-floss#485 Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
bab7a86 to
7fe52aa
Compare
llucax
left a comment
There was a problem hiding this comment.
This is not a fix for #485, at least not the solution proposed there. Besides having to plug this into the template, we should be able to ask for several different stub types. As the bindings we generate are for general use, I think it is good to still provide sync stubs too, we just need to use different packages for async and sync stubs to avoid the weirdness of having one only in the .pyi file.
So what I think we need is more a mapping between stub type and output directory, like: sync_only -> py/frequenz/client/xxx/, async_only -> py/frequenz/client/xxx/aio.
But actually I don't think that would work, as the full path is provided by the protobuf files themselves and we only pass py/ as the output dir.
So this probably needs more thought. Also, I think this issue is super low prio. The code to do this is not released yet, and things are working. This is just a minor tech debt issue.
| py_path: str | ||
| """The path of the root directory where the Python files will be generated.""" | ||
|
|
||
| grpc_stubs: str |
There was a problem hiding this comment.
I would name this just stub (or generated_stub to make it a bit more readable), as this is already about grpc as the module name indicates.
Add a new
grpc_stubsconfiguration option that allows users to choose which gRPC stubs to generate:sync_and_async: Generate both sync and async stubs (default)sync_only: Generate only synchronous stubsasync_only: Generate only asynchronous stubsThis uses the new
only_sync/only_asyncflags added in nipunn1313/mypy-protobuf#694.Note: This PR requires mypy-protobuf >= 3.8.0 which has not been released yet. The PR #694 was merged on Dec 15, 2025, but the latest release is still v3.7.0. This PR is marked as draft until a new mypy-protobuf release is available.
Fixes #485