diff --git a/homeassistant/components/ovo_energy/config_flow.py b/homeassistant/components/ovo_energy/config_flow.py index 9e406ce6b96..227182e5f99 100644 --- a/homeassistant/components/ovo_energy/config_flow.py +++ b/homeassistant/components/ovo_energy/config_flow.py @@ -1,10 +1,16 @@ """Config flow to configure the OVO Energy integration.""" +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any + import aiohttp from ovoenergy.ovoenergy import OVOEnergy import voluptuous as vol from homeassistant.config_entries import ConfigFlow from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.data_entry_flow import FlowResult from .const import CONF_ACCOUNT, DOMAIN @@ -28,7 +34,10 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN): self.username = None self.account = None - async def async_step_user(self, user_input=None): + async def async_step_user( + self, + user_input: Mapping[str, Any] | None = None, + ) -> FlowResult: """Handle a flow initiated by the user.""" errors = {} if user_input is not None: @@ -61,7 +70,10 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=USER_SCHEMA, errors=errors ) - async def async_step_reauth(self, user_input): + async def async_step_reauth( + self, + user_input: Mapping[str, Any], + ) -> FlowResult: """Handle configuration by re-auth.""" errors = {} @@ -84,15 +96,15 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN): else: if authenticated: entry = await self.async_set_unique_id(self.username) - self.hass.config_entries.async_update_entry( - entry, - data={ - CONF_USERNAME: self.username, - CONF_PASSWORD: user_input[CONF_PASSWORD], - CONF_ACCOUNT: self.account, - }, - ) - return self.async_abort(reason="reauth_successful") + if entry: + self.hass.config_entries.async_update_entry( + entry, + data={ + CONF_USERNAME: self.username, + CONF_PASSWORD: user_input[CONF_PASSWORD], + }, + ) + return self.async_abort(reason="reauth_successful") errors["base"] = "authorization_error"