@@ -152,25 +152,30 @@ def __init__(self, dispatcher: Dispatcher[Any, Any]) -> None:
152152 if TYPE_CHECKING : # pragma: no cover
153153
154154 @overload
155- def __get__ [O ](self , instance : None , owner : type [O ], / ) -> Dispatcher [I , O ]: ...
155+ def __get__ [Context ](
156+ self ,
157+ instance : None ,
158+ owner : type [Context ],
159+ / ,
160+ ) -> Dispatcher [I , Context ]: ...
156161
157162 @overload
158- def __get__ [O ](
163+ def __get__ [Context ](
159164 self ,
160- instance : O ,
161- owner : type [O ] | None = ...,
165+ instance : Context ,
166+ owner : type [Context ] | None = ...,
162167 / ,
163- ) -> Dispatcher [I , O ]: ...
168+ ) -> Dispatcher [I , Context ]: ...
164169
165170 @overload
166171 def __get__ (self , instance : None = ..., owner : None = ..., / ) -> Self : ...
167172
168- def __get__ [O ](
173+ def __get__ [Context ](
169174 self ,
170- instance : O | None = None ,
171- owner : type [O ] | None = None ,
175+ instance : Context | None = None ,
176+ owner : type [Context ] | None = None ,
172177 / ,
173- ) -> Self | Dispatcher [I , O ]:
178+ ) -> Self | Dispatcher [I , Context ]:
174179 if instance is None :
175180 if owner is None :
176181 return self
@@ -231,19 +236,19 @@ def decorator(wp: ConvertMethod[T, Any]) -> ConvertMethod[T, Any]:
231236
232237 return decorator (wrapped ) if wrapped else decorator
233238
234- async def __execute [O ](
239+ async def __execute [Context ](
235240 self ,
236241 input_value : I ,
237242 / ,
238243 * ,
239- context : O ,
240- context_type : type [O ] | None ,
241- ) -> O :
242- await self . __middleware_group . invoke (
243- lambda i : self .__steps .execute (i , context , context_type ),
244- input_value ,
245- )
246- return context
244+ context : Context ,
245+ context_type : type [Context ] | None ,
246+ ) -> Context :
247+ async def handler ( i : I , / ) -> Context :
248+ await self .__steps .execute (i , context , context_type )
249+ return context
250+
251+ return await self . __middleware_group . invoke ( handler , input_value )
247252
248253
249254@dataclass (repr = False , eq = False , frozen = True , slots = True )
0 commit comments