Change dict[str, Any] to FlowResultDict (#49546)

This commit is contained in:
Milan Meulemans 2021-04-23 05:23:15 +02:00 committed by GitHub
parent 686c92097f
commit 48695869f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 113 additions and 93 deletions

View file

@ -2,13 +2,13 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from bsblan import BSBLan, BSBLanError, Info from bsblan import BSBLan, BSBLanError, Info
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -25,7 +25,7 @@ class BSBLanFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if user_input is None: if user_input is None:
return self._show_setup_form() return self._show_setup_form()
@ -57,7 +57,7 @@ class BSBLanFlowHandler(ConfigFlow, domain=DOMAIN):
}, },
) )
def _show_setup_form(self, errors: dict | None = None) -> dict[str, Any]: def _show_setup_form(self, errors: dict | None = None) -> FlowResultDict:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",

View file

@ -11,6 +11,7 @@ import voluptuous as vol
from homeassistant.config_entries import CONN_CLASS_CLOUD_POLL, ConfigFlow, OptionsFlow from homeassistant.config_entries import CONN_CLASS_CLOUD_POLL, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
@ -52,13 +53,13 @@ class CanaryConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_import( async def async_step_import(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by configuration file.""" """Handle a flow initiated by configuration file."""
return await self.async_step_user(user_input) return await self.async_step_user(user_input)
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if self._async_current_entries(): if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")

View file

@ -22,6 +22,7 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -89,7 +90,7 @@ class ClimaCellOptionsConfigFlow(config_entries.OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Manage the ClimaCell options.""" """Manage the ClimaCell options."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) return self.async_create_entry(title="", data=user_input)
@ -122,7 +123,7 @@ class ClimaCellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:

View file

@ -6,6 +6,7 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResultDict
from . import get_coordinator from . import get_coordinator
from .const import DOMAIN, OPTION_WORLDWIDE from .const import DOMAIN, OPTION_WORLDWIDE
@ -21,7 +22,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}

View file

@ -13,6 +13,7 @@ from homeassistant import config_entries
from homeassistant.components import ssdp from homeassistant.components import ssdp
from homeassistant.const import CONF_HOST, CONF_TYPE from homeassistant.const import CONF_HOST, CONF_TYPE
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.httpx_client import get_async_client from homeassistant.helpers.httpx_client import get_async_client
from .receiver import ConnectDenonAVR from .receiver import ConnectDenonAVR
@ -134,7 +135,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_select( async def async_step_select(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle multiple receivers found.""" """Handle multiple receivers found."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -155,7 +156,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm( async def async_step_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Allow the user to confirm adding the device.""" """Allow the user to confirm adding the device."""
if user_input is not None: if user_input is not None:
return await self.async_step_connect() return await self.async_step_connect()
@ -165,7 +166,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_connect( async def async_step_connect(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Connect to the receiver.""" """Connect to the receiver."""
connect_denonavr = ConnectDenonAVR( connect_denonavr = ConnectDenonAVR(
self.host, self.host,
@ -214,7 +215,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
}, },
) )
async def async_step_ssdp(self, discovery_info: dict[str, Any]) -> dict[str, Any]: async def async_step_ssdp(self, discovery_info: dict[str, Any]) -> FlowResultDict:
"""Handle a discovered Denon AVR. """Handle a discovered Denon AVR.
This flow is triggered by the SSDP component. It will check if the This flow is triggered by the SSDP component. It will check if the

View file

@ -12,6 +12,7 @@ from homeassistant.components.ssdp import ATTR_SSDP_LOCATION, ATTR_UPNP_SERIAL
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
@ -47,7 +48,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if user_input is None: if user_input is None:
return self._show_setup_form() return self._show_setup_form()
@ -69,7 +70,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp( async def async_step_ssdp(
self, discovery_info: DiscoveryInfoType self, discovery_info: DiscoveryInfoType
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle SSDP discovery.""" """Handle SSDP discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
receiver_id = None receiver_id = None
@ -102,7 +103,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp_confirm( async def async_step_ssdp_confirm(
self, user_input: ConfigType = None self, user_input: ConfigType = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a confirmation flow initiated by SSDP.""" """Handle a confirmation flow initiated by SSDP."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -116,7 +117,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
data=self.discovery_info, data=self.discovery_info,
) )
def _show_setup_form(self, errors: dict | None = None) -> dict[str, Any]: def _show_setup_form(self, errors: dict | None = None) -> FlowResultDict:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",

View file

@ -9,6 +9,7 @@ import voluptuous as vol
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_SERIAL_NUMBER, DOMAIN from .const import CONF_SERIAL_NUMBER, DOMAIN
@ -26,7 +27,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if user_input is None: if user_input is None:
return self._async_show_setup_form() return self._async_show_setup_form()
@ -43,7 +44,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: dict[str, Any] self, discovery_info: dict[str, Any]
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
self.host = discovery_info[CONF_HOST] self.host = discovery_info[CONF_HOST]
self.port = discovery_info[CONF_PORT] self.port = discovery_info[CONF_PORT]
@ -61,14 +62,14 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm( async def async_step_zeroconf_confirm(
self, _: dict[str, Any] | None = None self, _: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by zeroconf.""" """Handle a flow initiated by zeroconf."""
return self._async_create_entry() return self._async_create_entry()
@callback @callback
def _async_show_setup_form( def _async_show_setup_form(
self, errors: dict[str, str] | None = None self, errors: dict[str, str] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
@ -82,7 +83,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
) )
@callback @callback
def _async_create_entry(self) -> dict[str, Any]: def _async_create_entry(self) -> FlowResultDict:
return self.async_create_entry( return self.async_create_entry(
title=self.serial_number, title=self.serial_number,
data={ data={

View file

@ -17,6 +17,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.httpx_client import get_async_client from homeassistant.helpers.httpx_client import get_async_client
@ -131,7 +132,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}

View file

@ -1,11 +1,10 @@
"""Config flow to configure the HomematicIP Cloud component.""" """Config flow to configure the HomematicIP Cloud component."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResultDict
from .const import ( from .const import (
_LOGGER, _LOGGER,
@ -29,11 +28,11 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow):
"""Initialize HomematicIP Cloud config flow.""" """Initialize HomematicIP Cloud config flow."""
self.auth = None self.auth = None
async def async_step_user(self, user_input=None) -> dict[str, Any]: async def async_step_user(self, user_input=None) -> FlowResultDict:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
return await self.async_step_init(user_input) return await self.async_step_init(user_input)
async def async_step_init(self, user_input=None) -> dict[str, Any]: async def async_step_init(self, user_input=None) -> FlowResultDict:
"""Handle a flow start.""" """Handle a flow start."""
errors = {} errors = {}
@ -64,7 +63,7 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow):
errors=errors, errors=errors,
) )
async def async_step_link(self, user_input=None) -> dict[str, Any]: async def async_step_link(self, user_input=None) -> FlowResultDict:
"""Attempt to link with the HomematicIP Cloud access point.""" """Attempt to link with the HomematicIP Cloud access point."""
errors = {} errors = {}
@ -86,7 +85,7 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow):
return self.async_show_form(step_id="link", errors=errors) return self.async_show_form(step_id="link", errors=errors)
async def async_step_import(self, import_info) -> dict[str, Any]: async def async_step_import(self, import_info) -> FlowResultDict:
"""Import a new access point as a config entry.""" """Import a new access point as a config entry."""
hapid = import_info[HMIPC_HAPID].replace("-", "").upper() hapid = import_info[HMIPC_HAPID].replace("-", "").upper()
authtoken = import_info[HMIPC_AUTHTOKEN] authtoken = import_info[HMIPC_AUTHTOKEN]

View file

@ -14,6 +14,7 @@ from homeassistant import config_entries, core
from homeassistant.components import ssdp from homeassistant.components import ssdp
from homeassistant.const import CONF_HOST, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_USERNAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from .bridge import authenticate_bridge from .bridge import authenticate_bridge
@ -117,7 +118,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_manual( async def async_step_manual(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle manual bridge setup.""" """Handle manual bridge setup."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -252,7 +253,7 @@ class HueOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Manage Hue options.""" """Manage Hue options."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) return self.async_create_entry(title="", data=user_input)

View file

@ -23,6 +23,7 @@ from homeassistant.const import (
CONF_SSL, CONF_SSL,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
@ -63,7 +64,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if user_input is None: if user_input is None:
return self._show_setup_form() return self._show_setup_form()
@ -99,7 +100,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=user_input[CONF_HOST], data=user_input) return self.async_create_entry(title=user_input[CONF_HOST], data=user_input)
async def async_step_zeroconf(self, discovery_info: ConfigType) -> dict[str, Any]: async def async_step_zeroconf(self, discovery_info: ConfigType) -> FlowResultDict:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
port = discovery_info[CONF_PORT] port = discovery_info[CONF_PORT]
zctype = discovery_info["type"] zctype = discovery_info["type"]
@ -167,7 +168,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm( async def async_step_zeroconf_confirm(
self, user_input: ConfigType = None self, user_input: ConfigType = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a confirmation flow initiated by zeroconf.""" """Handle a confirmation flow initiated by zeroconf."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -181,7 +182,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
data=self.discovery_info, data=self.discovery_info,
) )
def _show_setup_form(self, errors: dict | None = None) -> dict[str, Any]: def _show_setup_form(self, errors: dict | None = None) -> FlowResultDict:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",

View file

@ -10,6 +10,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import CONF_PORT from homeassistant.const import CONF_PORT
from homeassistant.data_entry_flow import FlowResultDict
from .const import DOMAIN from .const import DOMAIN
@ -21,7 +22,7 @@ class LiteJetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Create a LiteJet config entry based upon user input.""" """Create a LiteJet config entry based upon user input."""
if self.hass.config_entries.async_entries(DOMAIN): if self.hass.config_entries.async_entries(DOMAIN):
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")

View file

@ -1,13 +1,12 @@
"""Config flow to configure Met component.""" """Config flow to configure Met component."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from .const import ( from .const import (
@ -81,7 +80,7 @@ class MetFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=self._errors, errors=self._errors,
) )
async def async_step_import(self, user_input: dict | None = None) -> dict[str, Any]: async def async_step_import(self, user_input: dict | None = None) -> FlowResultDict:
"""Handle configuration by yaml file.""" """Handle configuration by yaml file."""
return await self.async_step_user(user_input) return await self.async_step_user(user_input)

View file

@ -27,6 +27,7 @@ from homeassistant.components.mysensors import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from . import CONF_RETAIN, CONF_VERSION, DEFAULT_VERSION from . import CONF_RETAIN, CONF_VERSION, DEFAULT_VERSION
@ -281,7 +282,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@callback @callback
def _async_create_entry( def _async_create_entry(
self, user_input: dict[str, str] | None = None self, user_input: dict[str, str] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Create the config entry.""" """Create the config entry."""
return self.async_create_entry( return self.async_create_entry(
title=f"{user_input[CONF_DEVICE]}", title=f"{user_input[CONF_DEVICE]}",

View file

@ -18,6 +18,7 @@ from homeassistant.const import (
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
@ -66,7 +67,7 @@ class NZBGetConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_import( async def async_step_import(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by configuration file.""" """Handle a flow initiated by configuration file."""
if CONF_SCAN_INTERVAL in user_input: if CONF_SCAN_INTERVAL in user_input:
user_input[CONF_SCAN_INTERVAL] = user_input[ user_input[CONF_SCAN_INTERVAL] = user_input[
@ -77,7 +78,7 @@ class NZBGetConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if self._async_current_entries(): if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")

View file

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from aiohttp import ContentTypeError from aiohttp import ContentTypeError
from requests.exceptions import ConnectTimeout, HTTPError from requests.exceptions import ConnectTimeout, HTTPError
@ -10,6 +9,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN from .const import DOMAIN
@ -37,7 +37,7 @@ class PlumLightpadConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initialized by the user or redirected to by import.""" """Handle a flow initialized by the user or redirected to by import."""
if not user_input: if not user_input:
return self._show_form() return self._show_form()
@ -61,6 +61,6 @@ class PlumLightpadConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_import( async def async_step_import(
self, import_config: ConfigType | None self, import_config: ConfigType | None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Import a config entry from configuration.yaml.""" """Import a config entry from configuration.yaml."""
return await self.async_step_user(import_config) return await self.async_step_user(import_config)

View file

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from urllib.parse import urlparse from urllib.parse import urlparse
from rokuecp import Roku, RokuError from rokuecp import Roku, RokuError
@ -16,6 +15,7 @@ from homeassistant.components.ssdp import (
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN from .const import DOMAIN
@ -54,7 +54,7 @@ class RokuConfigFlow(ConfigFlow, domain=DOMAIN):
self.discovery_info = {} self.discovery_info = {}
@callback @callback
def _show_form(self, errors: dict | None = None) -> dict[str, Any]: def _show_form(self, errors: dict | None = None) -> FlowResultDict:
"""Show the form to the user.""" """Show the form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
@ -62,7 +62,7 @@ class RokuConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors or {}, errors=errors or {},
) )
async def async_step_user(self, user_input: dict | None = None) -> dict[str, Any]: async def async_step_user(self, user_input: dict | None = None) -> FlowResultDict:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if not user_input: if not user_input:
return self._show_form() return self._show_form()
@ -115,7 +115,7 @@ class RokuConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp( async def async_step_ssdp(
self, discovery_info: dict | None = None self, discovery_info: dict | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initialized by discovery.""" """Handle a flow initialized by discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
name = discovery_info[ATTR_UPNP_FRIENDLY_NAME] name = discovery_info[ATTR_UPNP_FRIENDLY_NAME]
@ -141,7 +141,7 @@ class RokuConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm( async def async_step_discovery_confirm(
self, user_input: dict | None = None self, user_input: dict | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle user-confirmation of discovered device.""" """Handle user-confirmation of discovered device."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

@ -7,6 +7,7 @@ from rpi_bad_power import new_under_voltage
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
from .const import DOMAIN from .const import DOMAIN
@ -34,7 +35,7 @@ class RPiPowerFlow(DiscoveryFlowHandler, domain=DOMAIN):
async def async_step_onboarding( async def async_step_onboarding(
self, data: dict[str, Any] | None = None self, data: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initialized by onboarding.""" """Handle a flow initialized by onboarding."""
has_devices = await self._discovery_function(self.hass) has_devices = await self._discovery_function(self.hass)

View file

@ -9,6 +9,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
from .const import ( from .const import (
CONF_DSN, CONF_DSN,
@ -48,7 +49,7 @@ class SentryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a user config flow.""" """Handle a user config flow."""
if self._async_current_entries(): if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")
@ -79,7 +80,7 @@ class SentryOptionsFlow(config_entries.OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Manage Sentry options.""" """Manage Sentry options."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) return self.async_create_entry(title="", data=user_input)

View file

@ -16,6 +16,7 @@ from homeassistant.const import (
CONF_SSL, CONF_SSL,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -68,7 +69,7 @@ class SmaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""First step in config flow.""" """First step in config flow."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -117,7 +118,7 @@ class SmaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_import( async def async_step_import(
self, import_config: dict[str, Any] | None self, import_config: dict[str, Any] | None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Import a config flow from configuration.""" """Import a config flow from configuration."""
device_info = await validate_input(self.hass, import_config) device_info = await validate_input(self.hass, import_config)
import_config[DEVICE_INFO] = device_info import_config[DEVICE_INFO] = device_info

View file

@ -10,6 +10,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import CONF_API_KEY, CONF_NAME from homeassistant.const import CONF_API_KEY, CONF_NAME
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.util import slugify from homeassistant.util import slugify
from .const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN from .const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN
@ -56,7 +57,7 @@ class SolarEdgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Step when user initializes a integration.""" """Step when user initializes a integration."""
self._errors = {} self._errors = {}
if user_input is not None: if user_input is not None:
@ -92,7 +93,7 @@ class SolarEdgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_import( async def async_step_import(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Import a config entry.""" """Import a config entry."""
if self._site_in_configuration_exists(user_input[CONF_SITE_ID]): if self._site_in_configuration_exists(user_input[CONF_SITE_ID]):
return self.async_abort(reason="already_configured") return self.async_abort(reason="already_configured")

View file

@ -16,6 +16,7 @@ from homeassistant.const import (
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -75,7 +76,7 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return SonarrOptionsFlowHandler(config_entry) return SonarrOptionsFlowHandler(config_entry)
async def async_step_reauth(self, data: ConfigType | None = None) -> dict[str, Any]: async def async_step_reauth(self, data: ConfigType | None = None) -> FlowResultDict:
"""Handle configuration by re-auth.""" """Handle configuration by re-auth."""
self._reauth = True self._reauth = True
self._entry_data = dict(data) self._entry_data = dict(data)
@ -86,7 +87,7 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Confirm reauth dialog.""" """Confirm reauth dialog."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -100,7 +101,7 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
errors = {} errors = {}
@ -139,7 +140,7 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
async def _async_reauth_update_entry( async def _async_reauth_update_entry(
self, entry_id: str, data: dict self, entry_id: str, data: dict
) -> dict[str, Any]: ) -> FlowResultDict:
"""Update existing config entry.""" """Update existing config entry."""
entry = self.hass.config_entries.async_get_entry(entry_id) entry = self.hass.config_entries.async_get_entry(entry_id)
self.hass.config_entries.async_update_entry(entry, data=data) self.hass.config_entries.async_update_entry(entry, data=data)

View file

@ -9,6 +9,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import persistent_notification from homeassistant.components import persistent_notification
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from .const import DOMAIN, SPOTIFY_SCOPES from .const import DOMAIN, SPOTIFY_SCOPES
@ -38,7 +39,7 @@ class SpotifyFlowHandler(
"""Extra data that needs to be appended to the authorize url.""" """Extra data that needs to be appended to the authorize url."""
return {"scope": ",".join(SPOTIFY_SCOPES)} return {"scope": ",".join(SPOTIFY_SCOPES)}
async def async_oauth_create_entry(self, data: dict[str, Any]) -> dict[str, Any]: async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResultDict:
"""Create an entry for Spotify.""" """Create an entry for Spotify."""
spotify = Spotify(auth=data["token"]["access_token"]) spotify = Spotify(auth=data["token"]["access_token"])
@ -60,7 +61,7 @@ class SpotifyFlowHandler(
return self.async_create_entry(title=name, data=data) return self.async_create_entry(title=name, data=data)
async def async_step_reauth(self, entry: dict[str, Any]) -> dict[str, Any]: async def async_step_reauth(self, entry: dict[str, Any]) -> FlowResultDict:
"""Perform reauth upon migration of old entries.""" """Perform reauth upon migration of old entries."""
if entry: if entry:
self.entry = entry self.entry = entry
@ -76,7 +77,7 @@ class SpotifyFlowHandler(
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Confirm reauth dialog.""" """Confirm reauth dialog."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

@ -8,6 +8,7 @@ from toonapi import Agreement, Toon, ToonError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
@ -29,7 +30,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
"""Return logger.""" """Return logger."""
return logging.getLogger(__name__) return logging.getLogger(__name__)
async def async_oauth_create_entry(self, data: dict[str, Any]) -> dict[str, Any]: async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResultDict:
"""Test connection and load up agreements.""" """Test connection and load up agreements."""
self.data = data self.data = data
@ -49,7 +50,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
async def async_step_import( async def async_step_import(
self, config: dict[str, Any] | None = None self, config: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Start a configuration flow based on imported data. """Start a configuration flow based on imported data.
This step is merely here to trigger "discovery" when the `toon` This step is merely here to trigger "discovery" when the `toon`
@ -66,7 +67,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
async def async_step_agreement( async def async_step_agreement(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Select Toon agreement to add.""" """Select Toon agreement to add."""
if len(self.agreements) == 1: if len(self.agreements) == 1:
return await self._create_entry(self.agreements[0]) return await self._create_entry(self.agreements[0])
@ -87,7 +88,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
agreement_index = agreements_list.index(user_input[CONF_AGREEMENT]) agreement_index = agreements_list.index(user_input[CONF_AGREEMENT])
return await self._create_entry(self.agreements[agreement_index]) return await self._create_entry(self.agreements[agreement_index])
async def _create_entry(self, agreement: Agreement) -> dict[str, Any]: async def _create_entry(self, agreement: Agreement) -> FlowResultDict:
if CONF_MIGRATE in self.context: if CONF_MIGRATE in self.context:
await self.hass.config_entries.async_remove(self.context[CONF_MIGRATE]) await self.hass.config_entries.async_remove(self.context[CONF_MIGRATE])

View file

@ -13,6 +13,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_ID from homeassistant.const import CONF_ID
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_HOUSE_LETTER, CONF_HOUSE_NUMBER, CONF_POST_CODE, DOMAIN from .const import CONF_HOUSE_LETTER, CONF_HOUSE_NUMBER, CONF_POST_CODE, DOMAIN
@ -26,7 +27,7 @@ class TwenteMilieuFlowHandler(ConfigFlow, domain=DOMAIN):
async def _show_setup_form( async def _show_setup_form(
self, errors: dict[str, str] | None = None self, errors: dict[str, str] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
@ -42,7 +43,7 @@ class TwenteMilieuFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if user_input is None: if user_input is None:
return await self._show_setup_form(user_input) return await self._show_setup_form(user_input)

View file

@ -19,6 +19,7 @@ from homeassistant.config_entries import (
) )
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
from .const import ( from .const import (
CONF_GIID, CONF_GIID,
@ -57,7 +58,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -96,7 +97,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_installation( async def async_step_installation(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Select Verisure installation to add.""" """Select Verisure installation to add."""
if len(self.installations) == 1: if len(self.installations) == 1:
user_input = {CONF_GIID: list(self.installations)[0]} user_input = {CONF_GIID: list(self.installations)[0]}
@ -124,14 +125,14 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
}, },
) )
async def async_step_reauth(self, data: dict[str, Any]) -> dict[str, Any]: async def async_step_reauth(self, data: dict[str, Any]) -> FlowResultDict:
"""Handle initiation of re-authentication with Verisure.""" """Handle initiation of re-authentication with Verisure."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm() return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle re-authentication with Verisure.""" """Handle re-authentication with Verisure."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -173,7 +174,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
errors=errors, errors=errors,
) )
async def async_step_import(self, user_input: dict[str, Any]) -> dict[str, Any]: async def async_step_import(self, user_input: dict[str, Any]) -> FlowResultDict:
"""Import Verisure YAML configuration.""" """Import Verisure YAML configuration."""
if user_input[CONF_GIID]: if user_input[CONF_GIID]:
self.giid = user_input[CONF_GIID] self.giid = user_input[CONF_GIID]
@ -203,7 +204,7 @@ class VerisureOptionsFlowHandler(OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Manage Verisure options.""" """Manage Verisure options."""
errors = {} errors = {}

View file

@ -30,6 +30,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import DiscoveryInfoType from homeassistant.helpers.typing import DiscoveryInfoType
@ -111,7 +112,7 @@ class VizioOptionsConfigFlow(config_entries.OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Manage the vizio options.""" """Manage the vizio options."""
if user_input is not None: if user_input is not None:
if user_input.get(CONF_APPS_TO_INCLUDE_OR_EXCLUDE): if user_input.get(CONF_APPS_TO_INCLUDE_OR_EXCLUDE):
@ -193,7 +194,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._data = None self._data = None
self._apps = {} self._apps = {}
async def _create_entry(self, input_dict: dict[str, Any]) -> dict[str, Any]: async def _create_entry(self, input_dict: dict[str, Any]) -> FlowResultDict:
"""Create vizio config entry.""" """Create vizio config entry."""
# Remove extra keys that will not be used by entry setup # Remove extra keys that will not be used by entry setup
input_dict.pop(CONF_APPS_TO_INCLUDE_OR_EXCLUDE, None) input_dict.pop(CONF_APPS_TO_INCLUDE_OR_EXCLUDE, None)
@ -206,7 +207,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
errors = {} errors = {}
@ -279,7 +280,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="user", data_schema=schema, errors=errors) return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
async def async_step_import(self, import_config: dict[str, Any]) -> dict[str, Any]: async def async_step_import(self, import_config: dict[str, Any]) -> FlowResultDict:
"""Import a config entry from configuration.yaml.""" """Import a config entry from configuration.yaml."""
# Check if new config entry matches any existing config entries # Check if new config entry matches any existing config entries
for entry in self.hass.config_entries.async_entries(DOMAIN): for entry in self.hass.config_entries.async_entries(DOMAIN):
@ -343,7 +344,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType | None = None self, discovery_info: DiscoveryInfoType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
# If host already has port, no need to add it again # If host already has port, no need to add it again
if ":" not in discovery_info[CONF_HOST]: if ":" not in discovery_info[CONF_HOST]:
@ -380,7 +381,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pair_tv( async def async_step_pair_tv(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
""" """
Start pairing process for TV. Start pairing process for TV.
@ -445,7 +446,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors, errors=errors,
) )
async def _pairing_complete(self, step_id: str) -> dict[str, Any]: async def _pairing_complete(self, step_id: str) -> FlowResultDict:
"""Handle config flow completion.""" """Handle config flow completion."""
if not self._must_show_form: if not self._must_show_form:
return await self._create_entry(self._data) return await self._create_entry(self._data)
@ -459,7 +460,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pairing_complete( async def async_step_pairing_complete(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
""" """
Complete non-import sourced config flow. Complete non-import sourced config flow.
@ -469,7 +470,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pairing_complete_import( async def async_step_pairing_complete_import(
self, user_input: dict[str, Any] = None self, user_input: dict[str, Any] = None
) -> dict[str, Any]: ) -> FlowResultDict:
""" """
Complete import sourced config flow. Complete import sourced config flow.

View file

@ -1,8 +1,6 @@
"""Config flow to configure the WLED integration.""" """Config flow to configure the WLED integration."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from wled import WLED, WLEDConnectionError from wled import WLED, WLEDConnectionError
@ -12,6 +10,7 @@ from homeassistant.config_entries import (
ConfigFlow, ConfigFlow,
) )
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -26,13 +25,13 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: ConfigType | None = None self, user_input: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
return await self._handle_config_flow(user_input) return await self._handle_config_flow(user_input)
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: ConfigType | None = None self, discovery_info: ConfigType | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
if discovery_info is None: if discovery_info is None:
return self.async_abort(reason="cannot_connect") return self.async_abort(reason="cannot_connect")
@ -55,13 +54,13 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm( async def async_step_zeroconf_confirm(
self, user_input: ConfigType = None self, user_input: ConfigType = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle a flow initiated by zeroconf.""" """Handle a flow initiated by zeroconf."""
return await self._handle_config_flow(user_input) return await self._handle_config_flow(user_input)
async def _handle_config_flow( async def _handle_config_flow(
self, user_input: ConfigType | None = None, prepare: bool = False self, user_input: ConfigType | None = None, prepare: bool = False
) -> dict[str, Any]: ) -> FlowResultDict:
"""Config flow handler for WLED.""" """Config flow handler for WLED."""
source = self.context.get("source") source = self.context.get("source")
@ -102,7 +101,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
data={CONF_HOST: user_input[CONF_HOST], CONF_MAC: user_input[CONF_MAC]}, data={CONF_HOST: user_input[CONF_HOST], CONF_MAC: user_input[CONF_MAC]},
) )
def _show_setup_form(self, errors: dict | None = None) -> dict[str, Any]: def _show_setup_form(self, errors: dict | None = None) -> FlowResultDict:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
@ -110,7 +109,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
errors=errors or {}, errors=errors or {},
) )
def _show_confirm_dialog(self, errors: dict | None = None) -> dict[str, Any]: def _show_confirm_dialog(self, errors: dict | None = None) -> FlowResultDict:
"""Show the confirm dialog to the user.""" """Show the confirm dialog to the user."""
name = self.context.get(CONF_NAME) name = self.context.get(CONF_NAME)
return self.async_show_form( return self.async_show_form(

View file

@ -8,6 +8,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultDict
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from .const import DOMAIN from .const import DOMAIN
@ -69,7 +70,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> dict[str, Any]: ) -> FlowResultDict:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(