@@ -59,7 +59,13 @@ class WorkflowDefinition:
5959 Provides type safety and metadata for workflow classes.
6060 """
6161
62- def __init__ (self , cls : Type , name : str , run_method_name : str , signals : dict [str , Callable [..., Any ]]):
62+ def __init__ (
63+ self ,
64+ cls : Type ,
65+ name : str ,
66+ run_method_name : str ,
67+ signals : dict [str , Callable [..., Any ]],
68+ ):
6369 self ._cls = cls
6470 self ._name = name
6571 self ._run_method_name = run_method_name
@@ -106,7 +112,9 @@ def wrap(cls: Type, opts: WorkflowDefinitionOptions) -> "WorkflowDefinition":
106112 # Validate that the class has exactly one run method and find it
107113 # Also validate that class does not have multiple signal methods with the same name
108114 signals : dict [str , Callable [..., Any ]] = {}
109- signal_names : dict [str , str ] = {} # Map signal name to method name for duplicate detection
115+ signal_names : dict [
116+ str , str
117+ ] = {} # Map signal name to method name for duplicate detection
110118 run_method_name = None
111119 for attr_name in dir (cls ):
112120 if attr_name .startswith ("_" ):
@@ -123,7 +131,7 @@ def wrap(cls: Type, opts: WorkflowDefinitionOptions) -> "WorkflowDefinition":
123131 f"Multiple @workflow.run methods found in class { cls .__name__ } "
124132 )
125133 run_method_name = attr_name
126-
134+
127135 if hasattr (attr , "_workflow_signal" ):
128136 signal_name = getattr (attr , "_workflow_signal" )
129137 if signal_name in signal_names :
@@ -140,7 +148,6 @@ def wrap(cls: Type, opts: WorkflowDefinitionOptions) -> "WorkflowDefinition":
140148 return WorkflowDefinition (cls , name , run_method_name , signals )
141149
142150
143-
144151def run (func : Optional [T ] = None ) -> Union [T , Callable [[T ], T ]]:
145152 """
146153 Decorator to mark a method as the main workflow run method.
@@ -181,12 +188,13 @@ def decorator(f: T) -> T:
181188 # Called without parentheses: @workflow.run
182189 return decorator (func )
183190
191+
184192def signal (name : str | None = None ) -> Callable [[T ], T ]:
185193 """
186194 Decorator to mark a method as a workflow signal handler.
187195
188196 Example:
189- @workflow.signal(name="approval_channel")
197+ @workflow.signal(name="approval_channel")
190198 async def approve(self, approved: bool):
191199 self.approved = approved
192200
@@ -205,10 +213,12 @@ async def approve(self, approved: bool):
205213
206214 def decorator (f : T ) -> T :
207215 f ._workflow_signal = name # type: ignore
208- return f
216+ return f
217+
209218 # Only allow @workflow.signal(name), require name to be explicitly provided
210219 return decorator
211220
221+
212222@dataclass
213223class WorkflowInfo :
214224 workflow_type : str
0 commit comments