Add typings to OVO Energy integration (#75944)

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Aidan Timson 2023-01-16 22:26:40 +00:00 committed by GitHub
parent f0e6f45e43
commit 26c419705e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"