@@ -628,21 +628,6 @@ def _fetch_reference_injections( # noqa: C901
628628 return injections , closing
629629
630630
631- def _locate_dependent_closing_args (
632- provider : providers .Provider , closing_deps : Dict [str , providers .Provider ]
633- ) -> Dict [str , providers .Provider ]:
634- for arg in [
635- * getattr (provider , "args" , []),
636- * getattr (provider , "kwargs" , {}).values (),
637- ]:
638- if not isinstance (arg , providers .Provider ):
639- continue
640- if isinstance (arg , providers .Resource ):
641- closing_deps [str (id (arg ))] = arg
642-
643- _locate_dependent_closing_args (arg , closing_deps )
644-
645-
646631def _bind_injections (fn : Callable [..., Any ], providers_map : ProvidersMap ) -> None :
647632 patched_callable = _patched_registry .get_callable (fn )
648633 if patched_callable is None :
@@ -664,10 +649,9 @@ def _bind_injections(fn: Callable[..., Any], providers_map: ProvidersMap) -> Non
664649
665650 if injection in patched_callable .reference_closing :
666651 patched_callable .add_closing (injection , provider )
667- deps = {}
668- _locate_dependent_closing_args (provider , deps )
669- for key , dep in deps .items ():
670- patched_callable .add_closing (key , dep )
652+
653+ for resource in provider .traverse (types = [providers .Resource ]):
654+ patched_callable .add_closing (str (id (resource )), resource )
671655
672656
673657def _unbind_injections (fn : Callable [..., Any ]) -> None :
0 commit comments