@@ -175,23 +175,19 @@ def _register_op_factory(
175175 Register an op factory.
176176 """
177177
178- class _Fallback :
179- def enable_cache (self ) -> bool :
180- return op_args .cache
181-
182- def behavior_version (self ) -> int | None :
183- return op_args .behavior_version
184-
185- class _WrappedClass (executor_cls , _Fallback ): # type: ignore[misc]
178+ class _WrappedExecutor :
179+ _executor : Any
186180 _args_info : list [_ArgInfo ]
187181 _kwargs_info : dict [str , _ArgInfo ]
188182 _acall : Callable [..., Awaitable [Any ]]
189183 _result_encoder : Callable [[Any ], Any ]
190184
191185 def __init__ (self , spec : Any ) -> None :
192- super ().__init__ ()
193- self .spec = spec
194- self ._acall = _to_async_call (super ().__call__ )
186+ executor : Any = executor_class ()
187+ executor = executor_cls ()
188+ executor .spec = spec
189+ self ._executor = executor
190+ self ._acall = _to_async_call (executor .__call__ )
195191
196192 def analyze_schema (
197193 self , * args : _engine .OpArgSchema , ** kwargs : _engine .OpArgSchema
@@ -295,7 +291,7 @@ def process_arg(
295291 if len (missing_args ) > 0 :
296292 raise ValueError (f"Missing arguments: { ', ' .join (missing_args )} " )
297293
298- base_analyze_method = getattr (self , "analyze" , None )
294+ base_analyze_method = getattr (self . _executor , "analyze" , None )
299295 if base_analyze_method is not None :
300296 result_type = base_analyze_method (* args , ** kwargs )
301297 else :
@@ -317,7 +313,7 @@ async def prepare(self) -> None:
317313 Prepare for execution.
318314 It's executed after `analyze` and before any `__call__` execution.
319315 """
320- prepare_method = getattr (super () , "prepare" , None )
316+ prepare_method = getattr (self . _executor , "prepare" , None )
321317 if prepare_method is not None :
322318 await _to_async_call (prepare_method )()
323319
@@ -351,9 +347,15 @@ async def __call__(self, *args: Any, **kwargs: Any) -> Any:
351347 output = await self ._acall (* decoded_args , ** decoded_kwargs )
352348 return self ._result_encoder (output )
353349
350+ def enable_cache (self ) -> bool :
351+ return op_args .cache
352+
353+ def behavior_version (self ) -> int | None :
354+ return op_args .behavior_version
355+
354356 if category == OpCategory .FUNCTION :
355357 _engine .register_function_factory (
356- op_kind , _FunctionExecutorFactory (spec_cls , _WrappedClass )
358+ op_kind , _FunctionExecutorFactory (spec_cls , _WrappedExecutor )
357359 )
358360 else :
359361 raise ValueError (f"Unsupported executor type { category } " )
0 commit comments