diff --git a/homeassistant/components/solarlog/config_flow.py b/homeassistant/components/solarlog/config_flow.py index 6c170ed809e..054b0bb46a9 100644 --- a/homeassistant/components/solarlog/config_flow.py +++ b/homeassistant/components/solarlog/config_flow.py @@ -2,7 +2,7 @@ from collections.abc import Mapping import logging -from typing import TYPE_CHECKING, Any +from typing import Any from urllib.parse import ParseResult, urlparse from solarlog_cli.solarlog_connector import SolarLogConnector @@ -26,7 +26,7 @@ _LOGGER = logging.getLogger(__name__) class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for solarlog.""" - _entry: SolarlogConfigEntry | None = None + _entry: SolarlogConfigEntry VERSION = 1 MINOR_VERSION = 3 @@ -141,7 +141,7 @@ class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle a reconfiguration flow initialized by the user.""" - self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) + self._entry = self._get_reconfigure_entry() return await self.async_step_reconfigure_confirm() @@ -149,9 +149,6 @@ class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Handle a reconfiguration flow initialized by the user.""" - if TYPE_CHECKING: - assert self._entry is not None - if user_input is not None: if not user_input[CONF_HAS_PWD] or user_input.get(CONF_PASSWORD, "") == "": user_input[CONF_PASSWORD] = "" @@ -188,16 +185,13 @@ class SolarLogConfigFlow(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"]) + self._entry = self._get_reauth_entry() return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Handle reauthorization flow.""" - - assert self._entry is not None - if user_input and await self._test_extended_data( self._entry.data[CONF_HOST], user_input.get(CONF_PASSWORD, "") ):