From f37c0e0548b9a2b2680478e4e74d46198c239fb7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:03:19 +0200 Subject: [PATCH] Use reauth helpers in fyta (#128571) --- homeassistant/components/fyta/config_flow.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/fyta/config_flow.py b/homeassistant/components/fyta/config_flow.py index f2b5163c9db..78cb7647785 100644 --- a/homeassistant/components/fyta/config_flow.py +++ b/homeassistant/components/fyta/config_flow.py @@ -23,7 +23,6 @@ from homeassistant.helpers.selector import ( TextSelectorType, ) -from . import FytaConfigEntry from .const import CONF_EXPIRATION, DOMAIN _LOGGER = logging.getLogger(__name__) @@ -51,7 +50,6 @@ class FytaConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Fyta.""" credentials: Credentials - _entry: FytaConfigEntry | None = None VERSION = 1 MINOR_VERSION = 2 @@ -100,7 +98,6 @@ class FytaConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle flow upon an API authentication error.""" - self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( @@ -108,20 +105,21 @@ class FytaConfigFlow(ConfigFlow, domain=DOMAIN): ) -> ConfigFlowResult: """Handle reauthorization flow.""" errors = {} - assert self._entry is not None + reauth_entry = self._get_reauth_entry() if user_input and not (errors := await self.async_auth(user_input)): user_input |= { CONF_ACCESS_TOKEN: self.credentials.access_token, CONF_EXPIRATION: self.credentials.expiration.isoformat(), } return self.async_update_reload_and_abort( - self._entry, data={**self._entry.data, **user_input} + reauth_entry, + data_updates=user_input, ) data_schema = self.add_suggested_values_to_schema( DATA_SCHEMA, - {CONF_USERNAME: self._entry.data[CONF_USERNAME], **(user_input or {})}, + {CONF_USERNAME: reauth_entry.data[CONF_USERNAME], **(user_input or {})}, ) return self.async_show_form( step_id="reauth_confirm",