From 2e225dfc3a3ac72d2a5c73a426fef345ec37c39d Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:18:10 +0200 Subject: [PATCH] Use _get_reauth/reconfigure_entry in pyload (#127304) --- homeassistant/components/pyload/config_flow.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/pyload/config_flow.py b/homeassistant/components/pyload/config_flow.py index 79b90ff917d..f82156dc5d6 100644 --- a/homeassistant/components/pyload/config_flow.py +++ b/homeassistant/components/pyload/config_flow.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Mapping import logging -from typing import TYPE_CHECKING, Any +from typing import Any from aiohttp import CookieJar from pyloadapi.api import PyLoadAPI @@ -101,7 +101,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for pyLoad.""" VERSION = 1 - config_entry: PyLoadConfigEntry | None + config_entry: PyLoadConfigEntry async def async_step_user( self, user_input: dict[str, Any] | None = None @@ -156,9 +156,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - self.config_entry = self.hass.config_entries.async_get_entry( - self.context["entry_id"] - ) + self.config_entry = self._get_reauth_entry() return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( @@ -167,9 +165,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): """Dialog that informs the user that reauth is required.""" errors = {} - if TYPE_CHECKING: - assert self.config_entry - if user_input is not None: new_input = self.config_entry.data | user_input try: @@ -204,9 +199,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform a reconfiguration.""" - self.config_entry = self.hass.config_entries.async_get_entry( - self.context["entry_id"] - ) + self.config_entry = self._get_reconfigure_entry() return await self.async_step_reconfigure_confirm() async def async_step_reconfigure_confirm( @@ -215,9 +208,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): """Handle the reconfiguration flow.""" errors = {} - if TYPE_CHECKING: - assert self.config_entry - if user_input is not None: try: await validate_input(self.hass, user_input) -- GitLab