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

fix: Allow to inject async functions into async generators #124

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

Zhenay
Copy link
Contributor

@Zhenay Zhenay commented Aug 22, 2024

When you try to inject asynchronous dependencies into an asynchronous generator like this:

async def some_dep() -> int:
    return 5

@inject
async def some_async_gen(value: Annotated[int, Depends(some_dep)]):
    yield value

you see the error You cannot use async dependency `some_dep` at sync main.

This pull request allows the inject function be used in such context. Still do not work with asynccontextmanager decorator though.

@Lancetnik
Copy link
Owner

Great job, thank you!

@Lancetnik Lancetnik merged commit 5eeb685 into Lancetnik:main Aug 22, 2024
13 checks passed
Lancetnik added a commit that referenced this pull request Sep 5, 2024
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.

2 participants