Drop initialize_options helper from OptionsFlow (#129870)
This commit is contained in:
parent
27dc82d7d0
commit
79901cede9
3 changed files with 8 additions and 6 deletions
|
@ -3127,10 +3127,6 @@ class OptionsFlow(ConfigEntryBaseFlow):
|
|||
)
|
||||
self._config_entry = value
|
||||
|
||||
def initialize_options(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize the options to a mutable copy of the config entry options."""
|
||||
self._options = deepcopy(dict(config_entry.options))
|
||||
|
||||
@property
|
||||
def options(self) -> dict[str, Any]:
|
||||
"""Return a mutable copy of the config entry options.
|
||||
|
@ -3139,7 +3135,7 @@ class OptionsFlow(ConfigEntryBaseFlow):
|
|||
can only be referenced after initialisation.
|
||||
"""
|
||||
if not hasattr(self, "_options"):
|
||||
self.initialize_options(self.config_entry)
|
||||
self._options = deepcopy(dict(self.config_entry.options))
|
||||
return self._options
|
||||
|
||||
@options.setter
|
||||
|
|
|
@ -421,7 +421,9 @@ class SchemaOptionsFlowHandler(OptionsFlow):
|
|||
options, which is the union of stored options and user input from the options
|
||||
flow steps.
|
||||
"""
|
||||
self.initialize_options(config_entry)
|
||||
# Although `self.options` is most likely unused, it is safer to keep both
|
||||
# `self.options` and `self._common_handler.options` referring to the same object
|
||||
self._options = copy.deepcopy(dict(config_entry.options))
|
||||
self._common_handler = SchemaCommonFlowHandler(self, options_flow, self.options)
|
||||
self._async_options_flow_finished = async_options_flow_finished
|
||||
|
||||
|
|
|
@ -648,6 +648,10 @@ async def test_options_flow_state(hass: HomeAssistant) -> None:
|
|||
options_handler = hass.config_entries.options._progress[result["flow_id"]]
|
||||
assert options_handler._common_handler.flow_state == {"idx": None}
|
||||
|
||||
# Ensure that self.options and self._common_handler.options refer to the
|
||||
# same mutable copy of the options
|
||||
assert options_handler.options is options_handler._common_handler.options
|
||||
|
||||
# In step 1, flow state is updated with user input
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"option1": "blublu"}
|
||||
|
|
Loading…
Add table
Reference in a new issue