@@ -320,6 +320,7 @@ async def start_workflow(
320320 args : Sequence [Any ] = [],
321321 id : str ,
322322 task_queue : str ,
323+ result_type : Optional [Type ] = None ,
323324 execution_timeout : Optional [timedelta ] = None ,
324325 run_timeout : Optional [timedelta ] = None ,
325326 task_timeout : Optional [timedelta ] = None ,
@@ -343,6 +344,7 @@ async def start_workflow(
343344 args : Sequence [Any ] = [],
344345 id : str ,
345346 task_queue : str ,
347+ result_type : Optional [Type ] = None ,
346348 execution_timeout : Optional [timedelta ] = None ,
347349 run_timeout : Optional [timedelta ] = None ,
348350 task_timeout : Optional [timedelta ] = None ,
@@ -365,6 +367,8 @@ async def start_workflow(
365367 args: Multiple arguments to the workflow. Cannot be set if arg is.
366368 id: Unique identifier for the workflow execution.
367369 task_queue: Task queue to run the workflow on.
370+ result_type: For string workflows, this can set the specific result
371+ type hint to deserialize into.
368372 execution_timeout: Total workflow execution timeout including
369373 retries and continue as new.
370374 run_timeout: Timeout of a single workflow run.
@@ -390,13 +394,13 @@ async def start_workflow(
390394 """
391395 # Use definition if callable
392396 name : str
393- ret_type : Optional [Type ] = None
394397 if isinstance (workflow , str ):
395398 name = workflow
396399 elif callable (workflow ):
397400 defn = temporalio .workflow ._Definition .must_from_run_fn (workflow )
398401 name = defn .name
399- ret_type = defn .ret_type
402+ if result_type is None :
403+ result_type = defn .ret_type
400404 else :
401405 raise TypeError ("Workflow must be a string or callable" )
402406
@@ -417,7 +421,7 @@ async def start_workflow(
417421 headers = {},
418422 start_signal = start_signal ,
419423 start_signal_args = start_signal_args ,
420- ret_type = ret_type ,
424+ ret_type = result_type ,
421425 rpc_metadata = rpc_metadata ,
422426 rpc_timeout = rpc_timeout ,
423427 )
@@ -506,6 +510,7 @@ async def execute_workflow(
506510 args : Sequence [Any ] = [],
507511 id : str ,
508512 task_queue : str ,
513+ result_type : Optional [Type ] = None ,
509514 execution_timeout : Optional [timedelta ] = None ,
510515 run_timeout : Optional [timedelta ] = None ,
511516 task_timeout : Optional [timedelta ] = None ,
@@ -529,6 +534,7 @@ async def execute_workflow(
529534 args : Sequence [Any ] = [],
530535 id : str ,
531536 task_queue : str ,
537+ result_type : Optional [Type ] = None ,
532538 execution_timeout : Optional [timedelta ] = None ,
533539 run_timeout : Optional [timedelta ] = None ,
534540 task_timeout : Optional [timedelta ] = None ,
@@ -555,6 +561,7 @@ async def execute_workflow(
555561 arg ,
556562 args = args ,
557563 task_queue = task_queue ,
564+ result_type = result_type ,
558565 id = id ,
559566 execution_timeout = execution_timeout ,
560567 run_timeout = run_timeout ,
0 commit comments