@@ -628,21 +628,6 @@ def _fetch_reference_injections( # noqa: C901
628
628
return injections , closing
629
629
630
630
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
-
646
631
def _bind_injections (fn : Callable [..., Any ], providers_map : ProvidersMap ) -> None :
647
632
patched_callable = _patched_registry .get_callable (fn )
648
633
if patched_callable is None :
@@ -664,10 +649,9 @@ def _bind_injections(fn: Callable[..., Any], providers_map: ProvidersMap) -> Non
664
649
665
650
if injection in patched_callable .reference_closing :
666
651
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 )
671
655
672
656
673
657
def _unbind_injections (fn : Callable [..., Any ]) -> None :
0 commit comments