From a856abf47f006465572e403a6303c8b19e922ed7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 24 Nov 2022 14:43:40 +0100 Subject: [PATCH] Make async_options_flow_finished optional (#82615) * Make async_options_flow_finished optional * Adjust docstring --- homeassistant/helpers/schema_config_entry_flow.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/helpers/schema_config_entry_flow.py b/homeassistant/helpers/schema_config_entry_flow.py index 5dcda69aae0..39fa5164f62 100644 --- a/homeassistant/helpers/schema_config_entry_flow.py +++ b/homeassistant/helpers/schema_config_entry_flow.py @@ -309,9 +309,16 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry): self, config_entry: config_entries.ConfigEntry, options_flow: dict[str, SchemaFlowFormStep | SchemaFlowMenuStep], - async_options_flow_finished: Callable[[HomeAssistant, Mapping[str, Any]], None], + async_options_flow_finished: Callable[[HomeAssistant, Mapping[str, Any]], None] + | None = None, ) -> None: - """Initialize options flow.""" + """Initialize options flow. + + If needed, `async_options_flow_finished` can be set to take necessary actions + after the options flow is finished. The second parameter contains config entry + options, which is the union of stored options and user input from the options + flow steps. + """ super().__init__(config_entry) self._common_handler = SchemaCommonFlowHandler( self, options_flow, self._options @@ -346,7 +353,8 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry): **kwargs: Any, ) -> FlowResult: """Finish config flow and create a config entry.""" - self._async_options_flow_finished(self.hass, data) + if self._async_options_flow_finished: + self._async_options_flow_finished(self.hass, data) return super().async_create_entry(title="", data=data, **kwargs)