We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 80f1948 + 189c20d commit e6bc868Copy full SHA for e6bc868
src/inject/__init__.py
@@ -281,7 +281,14 @@ def __init__(self, cls: Binding) -> None:
281
self._cls = cls
282
283
def __get__(self, obj: Any, owner: Any) -> Injectable:
284
- return instance(self._cls)
+ inst = instance(self._cls)
285
+ if isinstance(inst, contextlib._AsyncGeneratorContextManager):
286
+ raise InjectorException(
287
+ 'Fail to load _AsyncGeneratorContextManager, Use autoparams, param or params instead of attr funcion')
288
+ elif isinstance(inst, contextlib._GeneratorContextManager):
289
+ with contextlib.ExitStack() as sync_stack:
290
+ inst = sync_stack.enter_context(inst)
291
+ return inst
292
293
294
class _AttributeInjectionDataclass(Generic[T]):
0 commit comments