diff --git a/homeassistant/components/august/config_flow.py b/homeassistant/components/august/config_flow.py index eb7bac9ae1a..067f986c4e6 100644 --- a/homeassistant/components/august/config_flow.py +++ b/homeassistant/components/august/config_flow.py @@ -1,11 +1,14 @@ """Config flow for August integration.""" +from collections.abc import Mapping import logging +from typing import Any import voluptuous as vol from yalexs.authenticator import ValidationResult from homeassistant import config_entries from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.data_entry_flow import FlowResult from .const import CONF_LOGIN_METHOD, DOMAIN, LOGIN_METHODS, VERIFICATION_CODE_KEY from .exceptions import CannotConnect, InvalidAuth, RequireValidation @@ -109,9 +112,9 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): }, ) - async def async_step_reauth(self, data): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Handle configuration by re-auth.""" - self._user_auth_details = dict(data) + self._user_auth_details = dict(entry_data) self._mode = "reauth" self._needs_reset = True self._august_gateway = AugustGateway(self.hass) diff --git a/homeassistant/components/azure_devops/config_flow.py b/homeassistant/components/azure_devops/config_flow.py index 350bad5852a..8fba3378886 100644 --- a/homeassistant/components/azure_devops/config_flow.py +++ b/homeassistant/components/azure_devops/config_flow.py @@ -1,9 +1,13 @@ """Config flow to configure the Azure DevOps integration.""" +from collections.abc import Mapping +from typing import Any + from aioazuredevops.client import DevOpsClient import aiohttp import voluptuous as vol from homeassistant.config_entries import ConfigFlow +from homeassistant.data_entry_flow import FlowResult from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN @@ -82,12 +86,12 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): return await self._show_setup_form(errors) return self._async_create_entry() - async def async_step_reauth(self, user_input): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Handle configuration by re-auth.""" - if user_input.get(CONF_ORG) and user_input.get(CONF_PROJECT): - self._organization = user_input[CONF_ORG] - self._project = user_input[CONF_PROJECT] - self._pat = user_input[CONF_PAT] + if entry_data.get(CONF_ORG) and entry_data.get(CONF_PROJECT): + self._organization = entry_data[CONF_ORG] + self._project = entry_data[CONF_PROJECT] + self._pat = entry_data[CONF_PAT] self.context["title_placeholders"] = { "project_url": f"{self._organization}/{self._project}", @@ -100,6 +104,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): return await self._show_reauth_form(errors) entry = await self.async_set_unique_id(self.unique_id) + assert entry self.hass.config_entries.async_update_entry( entry, data={ diff --git a/homeassistant/components/elmax/config_flow.py b/homeassistant/components/elmax/config_flow.py index 6872a555b8a..0c1a0148205 100644 --- a/homeassistant/components/elmax/config_flow.py +++ b/homeassistant/components/elmax/config_flow.py @@ -1,6 +1,7 @@ """Config flow for elmax-cloud integration.""" from __future__ import annotations +from collections.abc import Mapping import logging from typing import Any @@ -167,10 +168,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="panels", data_schema=self._panels_schema, errors=errors ) - async def async_step_reauth(self, user_input=None): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Perform reauth upon an API authentication error.""" - self._reauth_username = user_input.get(CONF_ELMAX_USERNAME) - self._reauth_panelid = user_input.get(CONF_ELMAX_PANEL_ID) + self._reauth_username = entry_data.get(CONF_ELMAX_USERNAME) + self._reauth_panelid = entry_data.get(CONF_ELMAX_PANEL_ID) return await self.async_step_reauth_confirm() async def async_step_reauth_confirm(self, user_input=None): diff --git a/homeassistant/components/hive/config_flow.py b/homeassistant/components/hive/config_flow.py index 5368aa22c3f..ec1c4f78e87 100644 --- a/homeassistant/components/hive/config_flow.py +++ b/homeassistant/components/hive/config_flow.py @@ -1,6 +1,9 @@ """Config Flow for Hive.""" from __future__ import annotations +from collections.abc import Mapping +from typing import Any + from apyhiveapi import Auth from apyhiveapi.helper.hive_exceptions import ( HiveApiError, @@ -13,6 +16,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME from homeassistant.core import callback +from homeassistant.data_entry_flow import FlowResult from .const import CONF_CODE, CONF_DEVICE_NAME, CONFIG_ENTRY_VERSION, DOMAIN @@ -136,11 +140,11 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_abort(reason="reauth_successful") return self.async_create_entry(title=self.data["username"], data=self.data) - async def async_step_reauth(self, user_input=None): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Re Authenticate a user.""" data = { - CONF_USERNAME: user_input[CONF_USERNAME], - CONF_PASSWORD: user_input[CONF_PASSWORD], + CONF_USERNAME: entry_data[CONF_USERNAME], + CONF_PASSWORD: entry_data[CONF_PASSWORD], } return await self.async_step_user(data) diff --git a/homeassistant/components/hyperion/config_flow.py b/homeassistant/components/hyperion/config_flow.py index 8b8f8b62c47..97e97cd835d 100644 --- a/homeassistant/components/hyperion/config_flow.py +++ b/homeassistant/components/hyperion/config_flow.py @@ -141,12 +141,9 @@ class HyperionConfigFlow(ConfigFlow, domain=DOMAIN): return await self.async_step_auth() return await self.async_step_confirm() - async def async_step_reauth( - self, - config_data: Mapping[str, Any], - ) -> FlowResult: + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Handle a reauthentication flow.""" - self._data = dict(config_data) + self._data = dict(entry_data) async with self._create_client(raw_connection=True) as hyperion_client: if not hyperion_client: return self.async_abort(reason="cannot_connect") diff --git a/homeassistant/components/mazda/config_flow.py b/homeassistant/components/mazda/config_flow.py index b1b0ce35b11..0b255483da1 100644 --- a/homeassistant/components/mazda/config_flow.py +++ b/homeassistant/components/mazda/config_flow.py @@ -1,5 +1,7 @@ """Config flow for Mazda Connected Services integration.""" +from collections.abc import Mapping import logging +from typing import Any import aiohttp from pymazda import ( @@ -11,6 +13,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_REGION +from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from .const import DOMAIN, MAZDA_REGIONS @@ -97,11 +100,11 @@ class MazdaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, user_input=None): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Perform reauth if the user credentials have changed.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] ) - self._email = user_input[CONF_EMAIL] - self._region = user_input[CONF_REGION] + self._email = entry_data[CONF_EMAIL] + self._region = entry_data[CONF_REGION] return await self.async_step_user() diff --git a/homeassistant/components/nuki/config_flow.py b/homeassistant/components/nuki/config_flow.py index 054d0aaa219..85144d9bb77 100644 --- a/homeassistant/components/nuki/config_flow.py +++ b/homeassistant/components/nuki/config_flow.py @@ -1,5 +1,7 @@ """Config flow to configure the Nuki integration.""" +from collections.abc import Mapping import logging +from typing import Any from pynuki import NukiBridge from pynuki.bridge import InvalidCredentialsException @@ -80,9 +82,9 @@ class NukiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_validate() - async def async_step_reauth(self, data): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Perform reauth upon an API authentication error.""" - self._data = data + self._data = entry_data return await self.async_step_reauth_confirm() diff --git a/homeassistant/components/plex/config_flow.py b/homeassistant/components/plex/config_flow.py index 3489e41364e..42d227154a6 100644 --- a/homeassistant/components/plex/config_flow.py +++ b/homeassistant/components/plex/config_flow.py @@ -1,8 +1,10 @@ """Config flow for Plex.""" from __future__ import annotations +from collections.abc import Mapping import copy import logging +from typing import Any from aiohttp import web_response import plexapi.exceptions @@ -26,6 +28,7 @@ from homeassistant.const import ( CONF_VERIFY_SSL, ) from homeassistant.core import callback +from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv @@ -329,9 +332,9 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): server_config = {CONF_TOKEN: self.token} return await self.async_step_server_validate(server_config) - async def async_step_reauth(self, data): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Handle a reauthorization flow request.""" - self.current_login = dict(data) + self.current_login = dict(entry_data) return await self.async_step_user() diff --git a/homeassistant/components/sense/config_flow.py b/homeassistant/components/sense/config_flow.py index 8769d4cb83f..0690344ccf1 100644 --- a/homeassistant/components/sense/config_flow.py +++ b/homeassistant/components/sense/config_flow.py @@ -1,5 +1,7 @@ """Config flow for Sense integration.""" +from collections.abc import Mapping import logging +from typing import Any from sense_energy import ( ASyncSenseable, @@ -10,6 +12,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_CODE, CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT +from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import ACTIVE_UPDATE_RATE, DEFAULT_TIMEOUT, DOMAIN, SENSE_CONNECT_EXCEPTIONS @@ -120,10 +123,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_reauth(self, data): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Handle configuration by re-auth.""" - self._auth_data = dict(data) - return await self.async_step_reauth_validate(data) + self._auth_data = dict(entry_data) + return await self.async_step_reauth_validate(entry_data) async def async_step_reauth_validate(self, user_input=None): """Handle reauth and validation.""" diff --git a/homeassistant/components/spotify/config_flow.py b/homeassistant/components/spotify/config_flow.py index 30ad74f8e26..013063308bb 100644 --- a/homeassistant/components/spotify/config_flow.py +++ b/homeassistant/components/spotify/config_flow.py @@ -57,7 +57,7 @@ class SpotifyFlowHandler( return self.async_create_entry(title=name, data=data) - async def async_step_reauth(self, entry: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Perform reauth upon migration of old entries.""" self.reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -65,7 +65,8 @@ class SpotifyFlowHandler( persistent_notification.async_create( self.hass, - f"Spotify integration for account {entry['id']} needs to be re-authenticated. Please go to the integrations page to re-configure it.", + f"Spotify integration for account {entry_data['id']} needs to be " + "re-authenticated. Please go to the integrations page to re-configure it.", "Spotify re-authentication", "spotify_reauth", ) diff --git a/homeassistant/components/totalconnect/config_flow.py b/homeassistant/components/totalconnect/config_flow.py index 057328cffb0..8d35506af0f 100644 --- a/homeassistant/components/totalconnect/config_flow.py +++ b/homeassistant/components/totalconnect/config_flow.py @@ -1,6 +1,9 @@ """Config flow for the Total Connect component.""" from __future__ import annotations +from collections.abc import Mapping +from typing import Any + from total_connect_client.client import TotalConnectClient from total_connect_client.exceptions import AuthenticationError import voluptuous as vol @@ -8,6 +11,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_LOCATION, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback +from homeassistant.data_entry_flow import FlowResult from .const import AUTO_BYPASS, CONF_USERCODES, DOMAIN @@ -121,10 +125,10 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): description_placeholders={"location_id": location_for_user}, ) - async def async_step_reauth(self, config): + async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: """Perform reauth upon an authentication error or no usercode.""" - self.username = config[CONF_USERNAME] - self.usercodes = config[CONF_USERCODES] + self.username = entry_data[CONF_USERNAME] + self.usercodes = entry_data[CONF_USERCODES] return await self.async_step_reauth_confirm()