Make async_options_flow_finished optional (#82615)

* Make async_options_flow_finished optional

* Adjust docstring
pull/82627/head
epenet 2022-11-24 14:43:40 +01:00 committed by GitHub
parent c0425619e2
commit a856abf47f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -309,9 +309,16 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
self, self,
config_entry: config_entries.ConfigEntry, config_entry: config_entries.ConfigEntry,
options_flow: dict[str, SchemaFlowFormStep | SchemaFlowMenuStep], 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: ) -> 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) super().__init__(config_entry)
self._common_handler = SchemaCommonFlowHandler( self._common_handler = SchemaCommonFlowHandler(
self, options_flow, self._options self, options_flow, self._options
@ -346,7 +353,8 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
**kwargs: Any, **kwargs: Any,
) -> FlowResult: ) -> FlowResult:
"""Finish config flow and create a config entry.""" """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) return super().async_create_entry(title="", data=data, **kwargs)