1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Add type hints to async_step_reauth in components (#74138)

This commit is contained in:
epenet 2022-06-29 10:21:58 +02:00 committed by GitHub
parent 6dc6e71f01
commit edc1ee2985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 10 deletions

View File

@ -1,6 +1,8 @@
"""Config flow for Bosch Smart Home Controller integration."""
from collections.abc import Mapping
import logging
from os import makedirs
from typing import Any
from boschshcpy import SHCRegisterClient, SHCSession
from boschshcpy.exceptions import (
@ -83,7 +85,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
host = None
hostname = None
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."""
return await self.async_step_reauth_confirm()

View File

@ -1,6 +1,7 @@
"""Config flow for Enphase Envoy integration."""
from __future__ import annotations
from collections.abc import Mapping
import contextlib
import logging
from typing import Any
@ -110,7 +111,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_user()
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."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]

View File

@ -1,6 +1,8 @@
"""Config flow for flume integration."""
from collections.abc import Mapping
import logging
import os
from typing import Any
from pyflume import FlumeAuth, FlumeDeviceList
from requests.exceptions import RequestException
@ -13,6 +15,7 @@ from homeassistant.const import (
CONF_PASSWORD,
CONF_USERNAME,
)
from homeassistant.data_entry_flow import FlowResult
from .const import BASE_TOKEN_FILENAME, DOMAIN
@ -103,7 +106,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=DATA_SCHEMA, errors=errors
)
async def async_step_reauth(self, user_input=None):
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
"""Handle reauth."""
self._reauth_unique_id = self.context["unique_id"]
return await self.async_step_reauth_confirm()

View File

@ -1,6 +1,7 @@
"""Config flow for IntelliFire integration."""
from __future__ import annotations
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any
@ -220,10 +221,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
LOGGER.debug("Running Step: manual_device_entry")
return await self.async_step_manual_device_entry()
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."""
LOGGER.debug("STEP: reauth")
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
assert entry
assert entry.unique_id
# populate the expected vars
self._serial = entry.unique_id

View File

@ -1,6 +1,9 @@
"""Config flow for Honeywell Lyric."""
from collections.abc import Mapping
import logging
from typing import Any
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow
from .const import DOMAIN
@ -18,7 +21,7 @@ class OAuth2FlowHandler(
"""Return logger."""
return logging.getLogger(__name__)
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."""
return await self.async_step_reauth_confirm()

View File

@ -1,5 +1,7 @@
"""Config flow for MyQ integration."""
from collections.abc import Mapping
import logging
from typing import Any
import pymyq
from pymyq.errors import InvalidCredentialsError, MyQError
@ -7,6 +9,7 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import DOMAIN
@ -60,7 +63,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=DATA_SCHEMA, errors=errors
)
async def async_step_reauth(self, user_input=None):
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
"""Handle reauth."""
self._reauth_unique_id = self.context["unique_id"]
return await self.async_step_reauth_confirm()

View File

@ -1,7 +1,9 @@
"""Config flow for Picnic integration."""
from __future__ import annotations
from collections.abc import Mapping
import logging
from typing import Any
from python_picnic_api import PicnicAPI
from python_picnic_api.session import PicnicAuthError
@ -11,6 +13,7 @@ import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_COUNTRY_CODE, COUNTRY_CODES, DOMAIN
@ -72,7 +75,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
async def async_step_reauth(self, _):
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
"""Perform the re-auth step upon an API authentication error."""
return await self.async_step_user()

View File

@ -1,5 +1,7 @@
"""Config flow for Prosegur Alarm integration."""
from collections.abc import Mapping
import logging
from typing import Any, cast
from pyprosegur.auth import COUNTRY, Auth
from pyprosegur.installation import Installation
@ -8,6 +10,7 @@ import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import CONF_COUNTRY, DOMAIN
@ -75,9 +78,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)
async def async_step_reauth(self, data):
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
"""Handle initiation of re-authentication with Prosegur."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
self.entry = cast(
ConfigEntry,
self.hass.config_entries.async_get_entry(self.context["entry_id"]),
)
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(self, user_input=None):

View File

@ -1,5 +1,7 @@
"""Adds config flow for Vulcan."""
from collections.abc import Mapping
import logging
from typing import Any
from aiohttp import ClientConnectionError
import voluptuous as vol
@ -16,6 +18,7 @@ from vulcan import (
from homeassistant import config_entries
from homeassistant.const import CONF_PIN, CONF_REGION, CONF_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import DOMAIN
@ -236,7 +239,7 @@ class VulcanFlowHandler(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 upon an API authentication error."""
return await self.async_step_reauth_confirm()