@@ -869,18 +869,18 @@ async def abind(
869869 args : Iterable [Any ] = (),
870870 kwargs : Mapping [str , Any ] | None = None ,
871871 ) -> Arguments :
872- bound = self .__bind (args , kwargs )
873- dependencies = await self .__dependencies .aget_arguments (exclude = bound . arguments )
874- return self .__build_arguments ( bound , dependencies )
872+ arguments = self .__get_arguments (args , kwargs )
873+ dependencies = await self .__dependencies .aget_arguments (exclude = arguments )
874+ return self .__merge_arguments ( arguments , dependencies )
875875
876876 def bind (
877877 self ,
878878 args : Iterable [Any ] = (),
879879 kwargs : Mapping [str , Any ] | None = None ,
880880 ) -> Arguments :
881- bound = self .__bind (args , kwargs )
882- dependencies = self .__dependencies .get_arguments (exclude = bound . arguments )
883- return self .__build_arguments ( bound , dependencies )
881+ arguments = self .__get_arguments (args , kwargs )
882+ dependencies = self .__dependencies .get_arguments (exclude = arguments )
883+ return self .__merge_arguments ( arguments , dependencies )
884884
885885 async def acall (self , / , * args : P .args , ** kwargs : P .kwargs ) -> T :
886886 with self .__lock :
@@ -929,29 +929,29 @@ def _(self, event: ModuleEvent, /) -> Iterator[None]:
929929 yield
930930 self .update (event .module )
931931
932- def __bind (
932+ def __get_arguments (
933933 self ,
934934 args : Iterable [Any ],
935935 kwargs : Mapping [str , Any ] | None ,
936- ) -> BoundArguments :
936+ ) -> dict [ str , Any ] :
937937 if kwargs is None :
938938 kwargs = {}
939939
940- return self .signature .bind_partial (* args , ** kwargs )
940+ return self .signature .bind_partial (* args , ** kwargs ).arguments
941+
942+ def __merge_arguments (
943+ self ,
944+ arguments : dict [str , Any ],
945+ other_arguments : dict [str , Any ],
946+ ) -> Arguments :
947+ bound = BoundArguments (self .signature , other_arguments | arguments ) # type: ignore[arg-type]
948+ return Arguments (bound .args , bound .kwargs )
941949
942950 def __run_tasks (self ) -> None :
943951 while tasks := self .__tasks :
944952 task = tasks .popleft ()
945953 task ()
946954
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-
955955
956956class InjectedFunction [** P , T ](HiddenCaller [P , T ], ABC ):
957957 __slots__ = ("__dict__" , "__injection_metadata__" )
0 commit comments