Skip to content

Commit

Permalink
Narrow down context manager check to only include generator context m…
Browse files Browse the repository at this point in the history
…anagers
  • Loading branch information
fzyukio committed Nov 14, 2023
1 parent 7d161d7 commit f98ac51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/inject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ async def async_injection_wrapper(*args: Any, **kwargs: Any) -> T:
for param, cls in params_to_provide.items():
if param not in provided_params:
inst = instance(cls)
if isinstance(inst, contextlib.AbstractContextManager):
if isinstance(inst, contextlib._GeneratorContextManager):
ctx_managers[param] = inst
elif isinstance(inst, contextlib.AbstractAsyncContextManager):
elif isinstance(inst, contextlib._AsyncGeneratorContextManager):
async_ctx_managers[param] = inst
else:
kwargs[param] = inst
Expand Down Expand Up @@ -372,7 +372,7 @@ def injection_wrapper(*args: Any, **kwargs: Any) -> T:
for param, cls in params_to_provide.items():
if param not in provided_params:
inst = instance(cls)
if isinstance(inst, contextlib.AbstractContextManager):
if isinstance(inst, contextlib._GeneratorContextManager):
ctx_managers[param] = inst
else:
kwargs[param] = inst
Expand Down

0 comments on commit f98ac51

Please sign in to comment.