Skip to content
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

Implement a new parameter to generate only async stubs #631

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

llucax
Copy link

@llucax llucax commented Sep 5, 2024

This commit adds a new parameter async_only to the plugin, that when present, will only generate the async stubs.

The current {}AsyncStub classes are fake, they are not present in the .py file, so they can only be used to write type hints. Using them also only works if the user manually casts the sync stub to the async stub.

Since most users will only want to use either the sync or the async stub, this new parameter will allow generating only the stubs that are suited for the user's use case, and allow them to have less hacky code.

Fixes #536.

This commit adds a new parameter `async_only` to the plugin, that when
present, will only generate the async stubs.

The current {}AsyncStub classes are "fake", they are not present in the
.py file, so they can only be used to write type hints. Using them also
only works if the user manually casts the sync stub to the async stub.

Since most users will only want to use either the sync or the async
stub, this new parameter will allow to generate only the stubs that are
suited for the user's use case, and allow them to have less hacky code.

Signed-off-by: Leandro Lucarella <[email protected]>
@llucax
Copy link
Author

llucax commented Sep 5, 2024

A draft until I get some confirmation that something like this would be accepted. Then I can continue updating the docs and tests (please let me know if anything should be updated).

@artificial-aidan
Copy link
Contributor

I think it would make more sense for this to be an enum option. Default to both, async only, sync only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A better way to annotation the AsyncStub
2 participants