From ba18571cbe06e557ed442fced0e9b86071ab11c7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 24 Nov 2022 14:37:55 +0100 Subject: [PATCH] Set last_step in SchemaCommonFlowHandler (#82616) * Set last_step in SchemaCommonFlowHandler * Always use boolean * Adjust next_step definition --- homeassistant/helpers/schema_config_entry_flow.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/helpers/schema_config_entry_flow.py b/homeassistant/helpers/schema_config_entry_flow.py index 13797483172..5dcda69aae0 100644 --- a/homeassistant/helpers/schema_config_entry_flow.py +++ b/homeassistant/helpers/schema_config_entry_flow.py @@ -42,8 +42,8 @@ class SchemaFlowFormStep: # The next_step function is called if the schema validates successfully or if no # schema is defined. The next_step function is passed the union of config entry # options and user input from previous steps. - # If next_step returns None, the flow is ended with FlowResultType.CREATE_ENTRY. - next_step: Callable[[dict[str, Any]], str | None] = lambda _: None + # If next_step is None, the flow is ended with FlowResultType.CREATE_ENTRY. + next_step: Callable[[dict[str, Any]], str] | None = None # Optional function to allow amending a form schema. # The update_form_schema function is called before async_show_form is called. The @@ -136,12 +136,11 @@ class SchemaCommonFlowHandler: next_step_id: str = step_id if user_input is not None or form_step.schema is None: # Get next step - next_step_id_or_end_flow = form_step.next_step(self._options) - if next_step_id_or_end_flow is None: + if form_step.next_step is None: # Flow done, create entry or update config entry options return self._handler.async_create_entry(data=self._options) - next_step_id = next_step_id_or_end_flow + next_step_id = form_step.next_step(self._options) return self._show_next_step(next_step_id) @@ -188,7 +187,10 @@ class SchemaCommonFlowHandler: # Show form for next step return self._handler.async_show_form( - step_id=next_step_id, data_schema=data_schema, errors=errors + step_id=next_step_id, + data_schema=data_schema, + errors=errors, + last_step=form_step.next_step is None, ) async def _async_menu_step(