Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align config flow type hints to scaffold #65157

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions homeassistant/components/canary/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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,
Expand Down Expand Up @@ -51,7 +50,7 @@ def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
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)
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/devolo_home_network/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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

Expand Down Expand Up @@ -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 = {}

Expand Down Expand Up @@ -92,7 +93,7 @@ async def async_step_zeroconf(
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]
Expand Down
26 changes: 18 additions & 8 deletions homeassistant/components/hue/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import asyncio
import logging
from typing import Any
from urllib.parse import urlparse

from aiohue import LinkButtonNotPressed, create_app_key
Expand All @@ -19,7 +20,6 @@
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,
Expand Down Expand Up @@ -59,7 +59,9 @@ def __init__(self) -> None:
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)
Expand All @@ -76,7 +78,9 @@ async def _get_bridge(
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:
Expand Down Expand Up @@ -126,7 +130,7 @@ async def async_step_init(self, user_input: ConfigType | None = None) -> FlowRes
)

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:
Expand All @@ -139,7 +143,9 @@ async def async_step_manual(
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
Expand Down Expand Up @@ -268,7 +274,7 @@ async def async_step_homekit(
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
Expand All @@ -291,7 +297,9 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""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)
Expand Down Expand Up @@ -324,7 +332,9 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""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)
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/iaqualink/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers.typing import ConfigType

from .const import DOMAIN

Expand Down Expand Up @@ -56,6 +55,6 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None):
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)
8 changes: 4 additions & 4 deletions homeassistant/components/lcn/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import logging
from typing import Any

import pypck

Expand All @@ -16,15 +17,14 @@
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

_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(
Expand All @@ -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]
Expand Down Expand Up @@ -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:
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
"""Import existing configuration from LCN."""
host_name = data[CONF_HOST]
# validate the imported connection parameters
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/notion/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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

Expand Down Expand Up @@ -74,7 +73,7 @@ async def _async_verify(self, step_id: str, schema: vol.Schema) -> FlowResult:

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()
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/nzbget/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import ConfigType

from .const import (
DEFAULT_NAME,
Expand Down Expand Up @@ -65,7 +64,7 @@ def async_get_options_flow(config_entry):
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:
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/plum_lightpad/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.typing import ConfigType

from .const import DOMAIN
from .utils import load_plum
Expand Down Expand Up @@ -60,6 +59,8 @@ async def async_step_user(
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)
3 changes: 1 addition & 2 deletions homeassistant/components/ridwell/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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

Expand Down Expand Up @@ -81,7 +80,7 @@ async def _async_validate(
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()
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/simplisafe/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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

Expand Down Expand Up @@ -85,7 +84,7 @@ def _async_show_form(self, *, errors: dict[str, Any] | None = None) -> FlowResul
},
)

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
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/switcher_kis/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

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
Expand All @@ -14,7 +13,7 @@
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")
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/tile/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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

Expand Down Expand Up @@ -75,7 +74,7 @@ async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
"""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()
Expand Down
13 changes: 8 additions & 5 deletions homeassistant/components/uptimerobot/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Config flow for UptimeRobot integration."""
from __future__ import annotations

from typing import Any

from pyuptimerobot import (
UptimeRobot,
UptimeRobotAccount,
Expand All @@ -15,7 +17,6 @@
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

Expand All @@ -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] = {}
Expand Down Expand Up @@ -61,7 +62,9 @@ async def _validate_input(

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
davet2001 marked this conversation as resolved.
Show resolved Hide resolved
) -> FlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(
Expand All @@ -79,13 +82,13 @@ async def async_step_user(self, user_input: ConfigType | None = None) -> FlowRes
)

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:
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/watttime/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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,
Expand Down Expand Up @@ -190,7 +189,7 @@ async def async_step_location(
)
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()
Expand Down