@@ -864,23 +864,21 @@ def signature(self) -> Signature:
864864 def wrapped (self ) -> Callable [P , T ]:
865865 return self .__wrapped
866866
867- async def abind (
868- self ,
869- args : Iterable [Any ] = (),
870- kwargs : Mapping [str , Any ] | None = None ,
871- ) -> Arguments :
872- bound = self .__bind (args , kwargs )
873- dependencies = await self .__dependencies .aget_arguments (exclude = bound .arguments )
874- return self .__build_arguments (bound , dependencies )
867+ async def abind (self , args : Iterable [Any ], kwargs : Mapping [str , Any ]) -> Arguments :
868+ arguments = self .__get_arguments (args , kwargs )
869+ dependencies = await self .__dependencies .aget_arguments (exclude = arguments )
870+ if dependencies :
871+ return self .__merge_arguments (arguments , dependencies )
875872
876- def bind (
877- self ,
878- args : Iterable [Any ] = (),
879- kwargs : Mapping [str , Any ] | None = None ,
880- ) -> Arguments :
881- bound = self .__bind (args , kwargs )
882- dependencies = self .__dependencies .get_arguments (exclude = bound .arguments )
883- return self .__build_arguments (bound , dependencies )
873+ return Arguments (args , kwargs )
874+
875+ def bind (self , args : Iterable [Any ], kwargs : Mapping [str , Any ]) -> Arguments :
876+ arguments = self .__get_arguments (args , kwargs )
877+ dependencies = self .__dependencies .get_arguments (exclude = arguments )
878+ if dependencies :
879+ return self .__merge_arguments (arguments , dependencies )
880+
881+ return Arguments (args , kwargs )
884882
885883 async def acall (self , / , * args : P .args , ** kwargs : P .kwargs ) -> T :
886884 with self .__lock :
@@ -929,29 +927,27 @@ def _(self, event: ModuleEvent, /) -> Iterator[None]:
929927 yield
930928 self .update (event .module )
931929
932- def __bind (
930+ def __get_arguments (
933931 self ,
934932 args : Iterable [Any ],
935- kwargs : Mapping [str , Any ] | None ,
936- ) -> BoundArguments :
937- if kwargs is None :
938- kwargs = {}
933+ kwargs : Mapping [str , Any ],
934+ ) -> dict [ str , Any ] :
935+ bound = self . signature . bind_partial ( * args , ** kwargs )
936+ return bound . arguments
939937
940- return self .signature .bind_partial (* args , ** kwargs )
938+ def __merge_arguments (
939+ self ,
940+ arguments : dict [str , Any ],
941+ additional_arguments : dict [str , Any ],
942+ ) -> Arguments :
943+ bound = BoundArguments (self .signature , additional_arguments | arguments ) # type: ignore[arg-type]
944+ return Arguments (bound .args , bound .kwargs )
941945
942946 def __run_tasks (self ) -> None :
943947 while tasks := self .__tasks :
944948 task = tasks .popleft ()
945949 task ()
946950
947- @staticmethod
948- def __build_arguments (
949- bound : BoundArguments ,
950- additional_arguments : dict [str , Any ],
951- ) -> Arguments :
952- bound .arguments = bound .arguments | additional_arguments
953- return Arguments (bound .args , bound .kwargs )
954-
955951
956952class InjectedFunction [** P , T ](HiddenCaller [P , T ], ABC ):
957953 __slots__ = ("__dict__" , "__injection_metadata__" )
0 commit comments