@@ -182,6 +182,7 @@ def warning_unhandled_request( # type: ignore
182182) -> str : # type: ignore
183183 filtered_body = _build_filtered_body (req .body )
184184 default_message = f"Unhandled request ({ filtered_body } )"
185+ is_async = type (req ) != BoltRequest
185186 if (
186187 is_workflow_step_edit (req .body )
187188 or is_workflow_step_save (req .body )
@@ -196,8 +197,8 @@ def warning_unhandled_request( # type: ignore
196197 return _build_unhandled_request_suggestion (
197198 default_message ,
198199 f"""
199- from slack_bolt.workflows.step import WorkflowStep
200- ws = WorkflowStep(
200+ from slack_bolt.workflows.step{ '.async_step' if is_async else '' } import { 'Async' if is_async else '' } WorkflowStep
201+ ws = { 'Async' if is_async else '' } WorkflowStep(
201202 callback_id="{ callback_id } ",
202203 edit=edit,
203204 save=save,
@@ -216,8 +217,8 @@ def warning_unhandled_request( # type: ignore
216217 default_message ,
217218 f"""
218219@app.action("{ action_id_or_callback_id } ")
219- def handle_some_action(ack, body, logger):
220- ack()
220+ { 'async ' if is_async else '' } def handle_some_action(ack, body, logger):
221+ { 'await ' if is_async else '' } ack()
221222 logger.info(body)
222223""" ,
223224 )
@@ -232,8 +233,8 @@ def handle_some_action(ack, body, logger):
232233 default_message ,
233234 f"""
234235@app.options({ constraints } )
235- def handle_some_options(ack):
236- ack(options=[ ... ])
236+ { 'async ' if is_async else '' } def handle_some_options(ack):
237+ { 'await ' if is_async else '' } ack(options=[ ... ])
237238""" ,
238239 )
239240 if is_shortcut (req .body ):
@@ -243,8 +244,8 @@ def handle_some_options(ack):
243244 default_message ,
244245 f"""
245246@app.shortcut("{ id } ")
246- def handle_shortcuts(ack, body, logger):
247- ack()
247+ { 'async ' if is_async else '' } def handle_shortcuts(ack, body, logger):
248+ { 'await ' if is_async else '' } ack()
248249 logger.info(body)
249250""" ,
250251 )
@@ -254,8 +255,8 @@ def handle_shortcuts(ack, body, logger):
254255 default_message ,
255256 f"""
256257@app.view("{ req .body .get ('view' , {}).get ('callback_id' , 'modal-view-id' )} ")
257- def handle_view_events(ack, body, logger):
258- ack()
258+ { 'async ' if is_async else '' } def handle_view_events(ack, body, logger):
259+ { 'await ' if is_async else '' } ack()
259260 logger.info(body)
260261""" ,
261262 )
@@ -266,7 +267,7 @@ def handle_view_events(ack, body, logger):
266267 default_message ,
267268 f"""
268269@app.event("{ event_type } ")
269- def handle_{ event_type } _events(body, logger):
270+ { 'async ' if is_async else '' } def handle_{ event_type } _events(body, logger):
270271 logger.info(body)
271272""" ,
272273 )
@@ -277,8 +278,8 @@ def handle_{event_type}_events(body, logger):
277278 default_message ,
278279 f"""
279280@app.command("{ command } ")
280- def handle_some_command(ack, body, logger):
281- ack()
281+ { 'async ' if is_async else '' } def handle_some_command(ack, body, logger):
282+ { 'await ' if is_async else '' } ack()
282283 logger.info(body)
283284""" ,
284285 )
0 commit comments