diff --git a/homeassistant/components/sfr_box/config_flow.py b/homeassistant/components/sfr_box/config_flow.py index a9bac9d1b84..322ce282333 100644 --- a/homeassistant/components/sfr_box/config_flow.py +++ b/homeassistant/components/sfr_box/config_flow.py @@ -39,7 +39,10 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 _box: SFRBox - _config: dict[str, Any] = {} + + def __init__(self) -> None: + """Initialize SFR Box flow.""" + self._config: dict[str, Any] = {} async def async_step_user( self, user_input: dict[str, str] | None = None @@ -47,6 +50,7 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a flow initialized by the user.""" errors = {} if user_input is not None: + self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]}) box = SFRBox( ip=user_input[CONF_HOST], client=async_get_clientsession(self.hass) ) @@ -60,7 +64,6 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN): assert system_info is not None await self.async_set_unique_id(system_info.mac_addr) self._abort_if_unique_id_configured() - self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]}) self._box = box self._config.update(user_input) return await self.async_step_choose_auth() diff --git a/homeassistant/components/sfr_box/quality_scale.yaml b/homeassistant/components/sfr_box/quality_scale.yaml index b0c008d6598..6f54c4f1045 100644 --- a/homeassistant/components/sfr_box/quality_scale.yaml +++ b/homeassistant/components/sfr_box/quality_scale.yaml @@ -1,13 +1,6 @@ rules: - # Special note, doesn't fall in any of the categories below - # Why can the coordinator state be None? As in, I understand that it can be None if it doesn't support it, but wouldn't these coordinators not be created at all? - ## Bronze - config-flow: - status: todo - comment: | - SFRBoxFlowHandler has a classvar _config. This can be dangerous - self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]}) can be tested at the first if statement + config-flow: done test-before-configure: done unique-config-entry: done config-flow-test-coverage: