Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Dec 15, 2025

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 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

@github-actions github-actions bot added part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:protobuf Affects the protobuf tools labels Dec 15, 2025
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>
@github-actions github-actions bot added the part:docs Affects the documentation label Dec 15, 2025
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:protobuf Affects the protobuf tools part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate a separate async-only stub

2 participants