@@ -796,26 +796,15 @@ def call_with_injection(self, callable, self_=None, args=(), kwargs={}):
796
796
:return: Value returned by callable.
797
797
"""
798
798
799
- def _get_callable_bindings (callable ):
800
- if not hasattr (callable , '__bindings__' ):
801
- return {}
802
-
803
- if callable .__bindings__ == 'deferred' :
804
- read_and_store_bindings (callable , _infer_injected_bindings (callable ))
805
- noninjectables = getattr (callable , '__noninjectables__' , set ())
806
- return {k : v for k , v in callable .__bindings__ .items () if k not in noninjectables }
807
-
808
- bindings = _get_callable_bindings (callable )
799
+ bindings = get_bindings (callable )
809
800
signature = inspect .signature (callable )
810
801
full_args = args
811
802
if self_ is not None :
812
803
full_args = (self_ ,) + full_args
813
804
bound_arguments = signature .bind_partial (* full_args )
814
805
815
806
needed = dict (
816
- (k , v )
817
- for (k , v ) in bindings .items ()
818
- if k not in kwargs and k not in bound_arguments .arguments
807
+ (k , v ) for (k , v ) in bindings .items () if k not in kwargs and k not in bound_arguments .arguments
819
808
)
820
809
821
810
dependencies = self .args_to_inject (
@@ -874,6 +863,16 @@ def repr_key(k):
874
863
return dependencies
875
864
876
865
866
+ def get_bindings (callable ):
867
+ if not hasattr (callable , '__bindings__' ):
868
+ return {}
869
+
870
+ if callable .__bindings__ == 'deferred' :
871
+ read_and_store_bindings (callable , _infer_injected_bindings (callable ))
872
+ noninjectables = getattr (callable , '__noninjectables__' , set ())
873
+ return {k : v for k , v in callable .__bindings__ .items () if k not in noninjectables }
874
+
875
+
877
876
class _BindingNotYetAvailable (Exception ):
878
877
pass
879
878
0 commit comments