mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
Align config flow type hints to scaffold (#65157)
This commit is contained in:
parent
6473edd88a
commit
0acfc7bbab
@ -12,7 +12,6 @@ from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
CONF_FFMPEG_ARGUMENTS,
|
||||
@ -51,7 +50,7 @@ class CanaryConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
return CanaryOptionsFlowHandler(config_entry)
|
||||
|
||||
async def async_step_import(
|
||||
self, user_input: ConfigType | None = None
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initiated by configuration file."""
|
||||
return await self.async_step_user(user_input)
|
||||
|
@ -13,7 +13,6 @@ from homeassistant.components import zeroconf
|
||||
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS, CONF_NAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, PRODUCT, SERIAL_NUMBER, TITLE
|
||||
|
||||
@ -48,7 +47,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict = {}
|
||||
|
||||
@ -92,7 +93,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return await self.async_step_zeroconf_confirm()
|
||||
|
||||
async def async_step_zeroconf_confirm(
|
||||
self, user_input: ConfigType | None = None
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initiated by zeroconf."""
|
||||
title = self.context["title_placeholders"][CONF_NAME]
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Any
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from aiohue import LinkButtonNotPressed, create_app_key
|
||||
@ -19,7 +20,6 @@ from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import aiohttp_client, device_registry
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
CONF_ALLOW_HUE_GROUPS,
|
||||
@ -59,7 +59,9 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.bridge: DiscoveredHueBridge | None = None
|
||||
self.discovered_bridges: dict[str, DiscoveredHueBridge] | None = None
|
||||
|
||||
async def async_step_user(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
# This is for backwards compatibility.
|
||||
return await self.async_step_init(user_input)
|
||||
@ -76,7 +78,9 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
assert bridge_id == bridge.id
|
||||
return bridge
|
||||
|
||||
async def async_step_init(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a flow start."""
|
||||
# Check if user chooses manual entry
|
||||
if user_input is not None and user_input["id"] == HUE_MANUAL_BRIDGE_ID:
|
||||
@ -126,7 +130,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
async def async_step_manual(
|
||||
self, user_input: ConfigType | None = None
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle manual bridge setup."""
|
||||
if user_input is None:
|
||||
@ -139,7 +143,9 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.bridge = await self._get_bridge(user_input[CONF_HOST])
|
||||
return await self.async_step_link()
|
||||
|
||||
async def async_step_link(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_link(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Attempt to link with the Hue bridge.
|
||||
|
||||
Given a configured host, will ask the user to press the link button
|
||||
@ -268,7 +274,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return await self.async_step_link()
|
||||
|
||||
async def async_step_import(self, import_info: ConfigType) -> FlowResult:
|
||||
async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult:
|
||||
"""Import a new bridge as a config entry.
|
||||
|
||||
This flow is triggered by `async_setup` for both configured and
|
||||
@ -291,7 +297,9 @@ class HueV1OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
"""Initialize Hue options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Manage Hue options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
@ -324,7 +332,9 @@ class HueV2OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
"""Initialize Hue options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Manage Hue options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
@ -12,7 +12,6 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -56,6 +55,6 @@ class AqualinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(self, user_input: ConfigType | None = None):
|
||||
async def async_step_import(self, user_input: dict[str, Any] | None = None):
|
||||
"""Occurs when an entry is setup through config."""
|
||||
return await self.async_step_user(user_input)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pypck
|
||||
|
||||
@ -16,7 +17,6 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN
|
||||
|
||||
@ -24,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_config_entry(
|
||||
hass: HomeAssistant, data: ConfigType
|
||||
hass: HomeAssistant, data: dict[str, Any]
|
||||
) -> config_entries.ConfigEntry | None:
|
||||
"""Check config entries for already configured entries based on the ip address/port."""
|
||||
return next(
|
||||
@ -38,7 +38,7 @@ def get_config_entry(
|
||||
)
|
||||
|
||||
|
||||
async def validate_connection(host_name: str, data: ConfigType) -> ConfigType:
|
||||
async def validate_connection(host_name: str, data: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Validate if a connection to LCN can be established."""
|
||||
host = data[CONF_IP_ADDRESS]
|
||||
port = data[CONF_PORT]
|
||||
@ -70,7 +70,7 @@ class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_import(self, data: ConfigType) -> FlowResult:
|
||||
async def async_step_import(self, data: dict[str, Any]) -> FlowResult:
|
||||
"""Import existing configuration from LCN."""
|
||||
host_name = data[CONF_HOST]
|
||||
# validate the imported connection parameters
|
||||
|
@ -11,7 +11,6 @@ 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 homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
|
||||
@ -74,7 +73,7 @@ class NotionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self.async_create_entry(title=self._username, data=data)
|
||||
|
||||
async def async_step_reauth(self, config: ConfigType) -> FlowResult:
|
||||
async def async_step_reauth(self, config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self._username = config[CONF_USERNAME]
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
@ -19,7 +19,6 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
DEFAULT_NAME,
|
||||
@ -65,7 +64,7 @@ class NZBGetConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
return NZBGetOptionsFlowHandler(config_entry)
|
||||
|
||||
async def async_step_import(
|
||||
self, user_input: ConfigType | None = None
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initiated by configuration file."""
|
||||
if CONF_SCAN_INTERVAL in user_input:
|
||||
|
@ -11,7 +11,6 @@ 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.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
from .utils import load_plum
|
||||
@ -60,6 +59,8 @@ class PlumLightpadConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
title=username, data={CONF_USERNAME: username, CONF_PASSWORD: password}
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_config: ConfigType | None) -> FlowResult:
|
||||
async def async_step_import(
|
||||
self, import_config: dict[str, Any] | None
|
||||
) -> FlowResult:
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
return await self.async_step_user(import_config)
|
||||
|
@ -11,7 +11,6 @@ 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, config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
|
||||
@ -81,7 +80,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
data={CONF_USERNAME: self._username, CONF_PASSWORD: self._password},
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, config: ConfigType) -> FlowResult:
|
||||
async def async_step_reauth(self, config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self._username = config[CONF_USERNAME]
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
@ -18,7 +18,6 @@ from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_URL, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import CONF_USER_ID, DOMAIN, LOGGER
|
||||
|
||||
@ -85,7 +84,7 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
},
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, config: ConfigType) -> FlowResult:
|
||||
async def async_step_reauth(self, config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self._username = config.get(CONF_USERNAME)
|
||||
self._reauth = True
|
||||
|
@ -5,7 +5,6 @@ from typing import Any
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DATA_DISCOVERY, DOMAIN
|
||||
from .utils import async_discover_devices
|
||||
@ -14,7 +13,7 @@ from .utils import async_discover_devices
|
||||
class SwitcherFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle Switcher config flow."""
|
||||
|
||||
async def async_step_import(self, import_config: ConfigType) -> FlowResult:
|
||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle a flow initiated by import."""
|
||||
if self._async_current_entries(True):
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
@ -11,7 +11,6 @@ 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 homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
|
||||
@ -75,7 +74,7 @@ class TileFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
return await self.async_step_user(import_config)
|
||||
|
||||
async def async_step_reauth(self, config: ConfigType) -> FlowResult:
|
||||
async def async_step_reauth(self, config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self._username = config[CONF_USERNAME]
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Config flow for UptimeRobot integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pyuptimerobot import (
|
||||
UptimeRobot,
|
||||
UptimeRobotAccount,
|
||||
@ -15,7 +17,6 @@ from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import API_ATTR_OK, DOMAIN, LOGGER
|
||||
|
||||
@ -28,7 +29,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
VERSION = 1
|
||||
|
||||
async def _validate_input(
|
||||
self, data: ConfigType
|
||||
self, data: dict[str, Any]
|
||||
) -> tuple[dict[str, str], UptimeRobotAccount | None]:
|
||||
"""Validate the user input allows us to connect."""
|
||||
errors: dict[str, str] = {}
|
||||
@ -61,7 +62,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return errors, account
|
||||
|
||||
async def async_step_user(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -79,13 +82,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
async def async_step_reauth(
|
||||
self, user_input: ConfigType | None = None
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Return the reauth confirm step."""
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: ConfigType | None = None
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Dialog that informs the user that reauth is required."""
|
||||
if user_input is None:
|
||||
|
@ -18,7 +18,6 @@ from homeassistant.const import (
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
CONF_BALANCING_AUTHORITY,
|
||||
@ -190,7 +189,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
return await self.async_step_coordinates()
|
||||
|
||||
async def async_step_reauth(self, config: ConfigType) -> FlowResult:
|
||||
async def async_step_reauth(self, config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self._data = {**config}
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
@ -20,7 +20,6 @@ from homeassistant.const import (
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from . import async_control_connect
|
||||
from .const import CONF_SOURCES, DEFAULT_NAME, DOMAIN, WEBOSTV_EXCEPTIONS
|
||||
@ -171,7 +170,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
self.host = config_entry.data[CONF_HOST]
|
||||
self.key = config_entry.data[CONF_CLIENT_SECRET]
|
||||
|
||||
async def async_step_init(self, user_input: ConfigType | None = None) -> FlowResult:
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Manage the options."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user