Closed fzyukio closed 7 months ago
Hi!
Quite an interesting change 👍. Never thought about such a case. Thank you. Could you please add comments to your code, explaining what it does? As you did in the pull request description.
Then I can merge PR and release the next version.
Hi @ivankorobkov thanks for checking it out. I've restructured it a bit and added some comments.
Hi, thank you.
I'll merge it tomorrow and make the next release.
@ivankorobkov Awesome! Thanks a lot for your quick action 👍
Allow a provider to be used as context manager
Problem statement:
bind
orbind_to_constructor
) or to a function decorated as a context manager leads to the context manager to be used as is, not viawith
statementProposed change:
async_injection_wrapper
andinjection_wrapper
: extract the provided instances fromkwargs
if they are subclasses ofAbstractContextManager
orAbstractAsyncContextManager
ExitStack
(and/orAsyncExitStack
) to enter all contexts, the return values are updated tokwargs
and finally sent to the functionTesting