From 46fa9e6b82c34bc020e158d484bc2240ac603036 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sat, 19 Oct 2024 14:32:26 +0200 Subject: [PATCH] Use new reauth helpers in transmission (#128765) --- .../components/transmission/config_flow.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/transmission/config_flow.py b/homeassistant/components/transmission/config_flow.py index 2a4fd5aae0b..731c3da532a 100644 --- a/homeassistant/components/transmission/config_flow.py +++ b/homeassistant/components/transmission/config_flow.py @@ -55,7 +55,6 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 MINOR_VERSION = 2 - _reauth_entry: ConfigEntry | None @staticmethod @callback @@ -100,9 +99,6 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - self._reauth_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( @@ -110,9 +106,9 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN): ) -> ConfigFlowResult: """Confirm reauth dialog.""" errors = {} - assert self._reauth_entry + reauth_entry = self._get_reauth_entry() if user_input is not None: - user_input = {**self._reauth_entry.data, **user_input} + user_input = {**reauth_entry.data, **user_input} try: await get_api(self.hass, user_input) @@ -121,16 +117,10 @@ class TransmissionFlowHandler(ConfigFlow, domain=DOMAIN): except (CannotConnect, UnknownError): errors["base"] = "cannot_connect" else: - self.hass.config_entries.async_update_entry( - self._reauth_entry, data=user_input - ) - await self.hass.config_entries.async_reload(self._reauth_entry.entry_id) - return self.async_abort(reason="reauth_successful") + return self.async_update_reload_and_abort(reauth_entry, data=user_input) return self.async_show_form( - description_placeholders={ - CONF_USERNAME: self._reauth_entry.data[CONF_USERNAME] - }, + description_placeholders={CONF_USERNAME: reauth_entry.data[CONF_USERNAME]}, step_id="reauth_confirm", data_schema=vol.Schema( {