File tree 1 file changed +9
-1
lines changed 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ def my_config(binder):
73
73
inject.configure(my_config)
74
74
75
75
"""
76
+ import asyncio
76
77
import contextlib
77
78
78
79
from inject ._version import __version__
@@ -281,7 +282,14 @@ def __init__(self, cls: Binding) -> None:
281
282
self ._cls = cls
282
283
283
284
def __get__ (self , obj : Any , owner : Any ) -> Injectable :
284
- return instance (self ._cls )
285
+ inst = instance (self ._cls )
286
+ if isinstance (inst , contextlib ._AsyncGeneratorContextManager ):
287
+ raise InjectorException (
288
+ 'Fail to load _AsyncGeneratorContextManager, Use autoparams, param or params instead of attr funcion' )
289
+ elif isinstance (inst , contextlib ._GeneratorContextManager ):
290
+ with contextlib .ExitStack () as sync_stack :
291
+ inst = sync_stack .enter_context (inst )
292
+ return inst
285
293
286
294
287
295
class _AttributeInjectionDataclass (Generic [T ]):
You can’t perform that action at this time.
0 commit comments