Skip to content

Generate a separate async-only stub #485

@llucax

Description

@llucax

What's needed?

Async stubs generated by mypy only exist in the pyi files, which leads to the interpreter to not know about their existence, ending with some hacks to be able to type-hint with them, but not being able to use them in any place the interpreter needs to understand them.

mypy-protobuf recently got a PR merged allowing to generate sync-only and async-only stubs:

When this is released, we should use to to remove the need for hacks to use async stubs.

Proposed solution

To keep backwards-compatibility, we probably want to generate a new async-only stub in a different file, for example we could have: frequenz.api.xxx.aio.yyyto mirror what we currently have in frequenz.api.xxx.yyy. Then we can declare asyncio support in the old location as deprecated, and finally generate sync-only stubs in the old location.

Use cases

No response

Alternatives and workarounds

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:cookiecutterAffects the generation of projects using cookiecutterpart:only-apiAffects the configuration of a api repopart:templateAffects the cookiecutter template filespart:toolingAffects the development tooling (CI, deployment, dependency management, etc.)type:enhancementNew feature or enhancement visitble to users

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions