From 6fe28d376415cba6f7dce1b562421c0f8b040763 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 29 Feb 2024 20:07:14 +0100 Subject: [PATCH] Migrate integrations a-d to generic flowhandler (#111861) --- homeassistant/components/abode/config_flow.py | 21 ++++---- .../components/accuweather/config_flow.py | 8 ++- .../components/acmeda/config_flow.py | 9 ++-- homeassistant/components/adax/config_flow.py | 11 ++-- .../components/adguard/config_flow.py | 15 +++--- .../components/advantage_air/config_flow.py | 7 ++- homeassistant/components/aemet/config_flow.py | 9 ++-- .../components/aftership/config_flow.py | 7 ++- .../components/agent_dvr/config_flow.py | 7 ++- homeassistant/components/airly/config_flow.py | 7 ++- .../components/airnow/config_flow.py | 11 ++-- homeassistant/components/airq/config_flow.py | 7 ++- .../components/airthings/config_flow.py | 7 ++- .../components/airthings_ble/config_flow.py | 9 ++-- .../components/airtouch4/config_flow.py | 4 +- .../components/airtouch5/config_flow.py | 3 +- .../components/airvisual/config_flow.py | 24 ++++----- .../components/airvisual_pro/config_flow.py | 18 ++++--- .../components/airzone/config_flow.py | 14 +++--- .../components/airzone_cloud/config_flow.py | 9 ++-- .../components/aladdin_connect/config_flow.py | 15 +++--- .../components/alarmdecoder/config_flow.py | 29 ++++++----- .../components/amberelectric/config_flow.py | 9 ++-- .../components/ambiclimate/config_flow.py | 11 ++-- .../components/ambient_station/config_flow.py | 9 ++-- .../analytics_insights/config_flow.py | 6 +-- .../android_ip_webcam/config_flow.py | 7 ++- .../components/androidtv/config_flow.py | 20 ++++---- .../androidtv_remote/config_flow.py | 20 ++++---- homeassistant/components/anova/config_flow.py | 5 +- .../components/anthemav/config_flow.py | 5 +- .../components/aosmith/config_flow.py | 13 ++--- .../components/apcupsd/config_flow.py | 5 +- .../components/apple_tv/config_flow.py | 50 +++++++++++-------- .../components/aprilaire/config_flow.py | 3 +- .../components/aranet/config_flow.py | 12 ++--- .../components/arcam_fmj/config_flow.py | 17 ++++--- .../components/aseko_pool_live/config_flow.py | 7 ++- .../components/asuswrt/config_flow.py | 11 ++-- homeassistant/components/atag/config_flow.py | 11 ++-- .../components/august/config_flow.py | 21 ++++---- .../components/aurora/config_flow.py | 9 ++-- .../aurora_abb_powerone/config_flow.py | 10 ++-- .../aussie_broadband/config_flow.py | 13 ++--- homeassistant/components/awair/config_flow.py | 21 ++++---- homeassistant/components/aws/config_flow.py | 9 ++-- homeassistant/components/axis/config_flow.py | 40 +++++++++------ .../components/azure_devops/config_flow.py | 15 +++--- .../components/azure_event_hub/config_flow.py | 17 ++++--- homeassistant/components/baf/config_flow.py | 11 ++-- .../components/balboa/config_flow.py | 9 ++-- .../components/bang_olufsen/config_flow.py | 11 ++-- .../components/blebox/config_flow.py | 9 ++-- homeassistant/components/blink/config_flow.py | 13 ++--- .../components/blue_current/config_flow.py | 13 ++--- .../components/bluemaestro/config_flow.py | 9 ++-- .../components/bluetooth/config_flow.py | 15 +++--- .../bmw_connected_drive/config_flow.py | 37 ++++++++------ homeassistant/components/bond/config_flow.py | 15 +++--- .../components/bosch_shc/config_flow.py | 19 +++---- .../components/braviatv/config_flow.py | 28 ++++++----- homeassistant/components/bring/config_flow.py | 3 +- .../components/broadlink/config_flow.py | 25 +++++++--- .../components/brother/config_flow.py | 14 +++--- .../brottsplatskartan/config_flow.py | 7 ++- homeassistant/components/brunt/config_flow.py | 11 ++-- .../components/bsblan/config_flow.py | 9 ++-- .../components/bthome/config_flow.py | 19 ++++--- .../components/buienradar/config_flow.py | 8 ++- .../components/caldav/config_flow.py | 15 +++--- .../components/canary/config_flow.py | 14 ++++-- homeassistant/components/cast/config_flow.py | 18 ++++--- homeassistant/components/ccm15/config_flow.py | 7 ++- .../components/cert_expiry/config_flow.py | 11 ++-- homeassistant/components/cloud/config_flow.py | 5 +- .../components/cloudflare/config_flow.py | 15 +++--- .../components/co2signal/config_flow.py | 18 +++---- .../components/coinbase/config_flow.py | 43 ++++++++-------- .../components/color_extractor/config_flow.py | 8 +-- .../components/comelit/config_flow.py | 22 ++++---- .../components/control4/config_flow.py | 15 +++--- .../components/coolmaster/config_flow.py | 7 ++- .../components/cpuspeed/config_flow.py | 5 +- .../components/crownstone/config_flow.py | 27 ++++++---- .../components/daikin/config_flow.py | 13 +++-- .../components/deconz/config_flow.py | 38 ++++++++------ .../components/deluge/config_flow.py | 9 ++-- homeassistant/components/demo/config_flow.py | 26 ++++++---- .../components/denonavr/config_flow.py | 30 ++++++----- .../components/devialet/config_flow.py | 11 ++-- .../devolo_home_control/config_flow.py | 22 ++++---- .../devolo_home_network/config_flow.py | 20 ++++---- .../components/dexcom/config_flow.py | 10 ++-- .../components/directv/config_flow.py | 13 ++--- .../components/discord/config_flow.py | 13 ++--- .../components/discovergy/config_flow.py | 14 +++--- homeassistant/components/dlink/config_flow.py | 13 ++--- .../components/dlna_dmr/config_flow.py | 42 ++++++++++------ .../components/dlna_dms/config_flow.py | 16 +++--- homeassistant/components/dnsip/config_flow.py | 20 +++++--- .../components/doorbird/config_flow.py | 31 ++++++------ .../components/dormakaba_dkey/config_flow.py | 21 ++++---- .../dremel_3d_printer/config_flow.py | 7 ++- .../components/drop_connect/config_flow.py | 13 ++--- homeassistant/components/dsmr/config_flow.py | 34 +++++++------ .../components/dsmr_reader/config_flow.py | 4 +- .../components/dunehd/config_flow.py | 12 ++--- .../components/duotecno/config_flow.py | 7 ++- .../dwd_weather_warnings/config_flow.py | 5 +- .../components/dynalite/config_flow.py | 11 ++-- .../components/aussie_broadband/test_init.py | 2 +- 111 files changed, 841 insertions(+), 758 deletions(-) diff --git a/homeassistant/components/abode/config_flow.py b/homeassistant/components/abode/config_flow.py index 56cd673bc1b..21d8872088f 100644 --- a/homeassistant/components/abode/config_flow.py +++ b/homeassistant/components/abode/config_flow.py @@ -14,16 +14,15 @@ from jaraco.abode.helpers.errors import MFA_CODE_REQUIRED from requests.exceptions import ConnectTimeout, HTTPError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from .const import CONF_POLLING, DOMAIN, LOGGER CONF_MFA = "mfa_code" -class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AbodeFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Abode.""" VERSION = 1 @@ -43,7 +42,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._polling: bool = False self._username: str | None = None - async def _async_abode_login(self, step_id: str) -> FlowResult: + async def _async_abode_login(self, step_id: str) -> ConfigFlowResult: """Handle login with Abode.""" errors = {} @@ -74,7 +73,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self._async_create_entry() - async def _async_abode_mfa_login(self) -> FlowResult: + async def _async_abode_mfa_login(self) -> ConfigFlowResult: """Handle multi-factor authentication (MFA) login with Abode.""" try: # Create instance to access login method for passing MFA code @@ -92,7 +91,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self._async_create_entry() - async def _async_create_entry(self) -> FlowResult: + async def _async_create_entry(self) -> ConfigFlowResult: """Create the config entry.""" config_data = { CONF_USERNAME: self._username, @@ -118,7 +117,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -135,7 +134,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_mfa( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a multi-factor authentication (MFA) flow.""" if user_input is None: return self.async_show_form( @@ -146,7 +145,9 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self._async_abode_mfa_login() - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauthorization request from Abode.""" self._username = entry_data[CONF_USERNAME] @@ -154,7 +155,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle reauthorization flow.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/accuweather/config_flow.py b/homeassistant/components/accuweather/config_flow.py index b3fc7872c85..fe9565a9e2e 100644 --- a/homeassistant/components/accuweather/config_flow.py +++ b/homeassistant/components/accuweather/config_flow.py @@ -9,11 +9,9 @@ from aiohttp import ClientError from aiohttp.client_exceptions import ClientConnectorError import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.schema_config_entry_flow import ( @@ -33,14 +31,14 @@ OPTIONS_FLOW = { } -class AccuWeatherFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AccuWeatherFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for AccuWeather.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" # Under the terms of use of the API, one user can use one free API key. Due to # the small number of requests allowed, we only allow one integration instance. diff --git a/homeassistant/components/acmeda/config_flow.py b/homeassistant/components/acmeda/config_flow.py index 56a11aff200..f705e78d483 100644 --- a/homeassistant/components/acmeda/config_flow.py +++ b/homeassistant/components/acmeda/config_flow.py @@ -8,14 +8,13 @@ from typing import Any import aiopulse import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_ID -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN -class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AcmedaFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Acmeda config flow.""" VERSION = 1 @@ -26,7 +25,7 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if ( user_input is not None @@ -66,7 +65,7 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ), ) - async def async_create(self, hub: aiopulse.Hub) -> FlowResult: + async def async_create(self, hub: aiopulse.Hub) -> ConfigFlowResult: """Create the Acmeda Hub entry.""" await self.async_set_unique_id(hub.id, raise_on_progress=False) return self.async_create_entry(title=hub.id, data={CONF_HOST: hub.host}) diff --git a/homeassistant/components/adax/config_flow.py b/homeassistant/components/adax/config_flow.py index b614c968d48..6defde6f508 100644 --- a/homeassistant/components/adax/config_flow.py +++ b/homeassistant/components/adax/config_flow.py @@ -8,14 +8,13 @@ import adax import adax_local import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_IP_ADDRESS, CONF_PASSWORD, CONF_TOKEN, CONF_UNIQUE_ID, ) -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import ( @@ -31,14 +30,14 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AdaxConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Adax.""" VERSION = 2 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" data_schema = vol.Schema( { @@ -63,7 +62,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_local( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the local step.""" data_schema = vol.Schema( {vol.Required(WIFI_SSID): str, vol.Required(WIFI_PSWD): str} @@ -110,7 +109,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_cloud( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the cloud step.""" data_schema = vol.Schema( {vol.Required(ACCOUNT_ID): int, vol.Required(CONF_PASSWORD): str} diff --git a/homeassistant/components/adguard/config_flow.py b/homeassistant/components/adguard/config_flow.py index bc9b11c9a72..cf88674a815 100644 --- a/homeassistant/components/adguard/config_flow.py +++ b/homeassistant/components/adguard/config_flow.py @@ -7,7 +7,7 @@ from adguardhome import AdGuardHome, AdGuardHomeConnectionError import voluptuous as vol from homeassistant.components.hassio import HassioServiceInfo -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -16,7 +16,6 @@ from homeassistant.const import ( CONF_USERNAME, CONF_VERIFY_SSL, ) -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -31,7 +30,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN): async def _show_setup_form( self, errors: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the setup form to the user.""" return self.async_show_form( step_id="user", @@ -50,7 +49,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN): async def _show_hassio_form( self, errors: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the Hass.io confirmation form to the user.""" assert self._hassio_discovery return self.async_show_form( @@ -61,7 +60,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if user_input is None: return await self._show_setup_form(user_input) @@ -104,7 +103,9 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN): }, ) - async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult: + async def async_step_hassio( + self, discovery_info: HassioServiceInfo + ) -> ConfigFlowResult: """Prepare configuration for a Hass.io AdGuard Home add-on. This flow is triggered by the discovery component. @@ -116,7 +117,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_hassio_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm Supervisor discovery.""" if user_input is None: return await self._show_hassio_form() diff --git a/homeassistant/components/advantage_air/config_flow.py b/homeassistant/components/advantage_air/config_flow.py index 7b5acab55f0..e80e884e4d9 100644 --- a/homeassistant/components/advantage_air/config_flow.py +++ b/homeassistant/components/advantage_air/config_flow.py @@ -6,9 +6,8 @@ from typing import Any from advantage_air import ApiError, advantage_air import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import ADVANTAGE_AIR_RETRY, DOMAIN @@ -23,7 +22,7 @@ ADVANTAGE_AIR_SCHEMA = vol.Schema( ) -class AdvantageAirConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AdvantageAirConfigFlow(ConfigFlow, domain=DOMAIN): """Config Advantage Air API connection.""" VERSION = 1 @@ -32,7 +31,7 @@ class AdvantageAirConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Get configuration from the user.""" errors = {} if user_input: diff --git a/homeassistant/components/aemet/config_flow.py b/homeassistant/components/aemet/config_flow.py index bb73311aa55..a402eb290b8 100644 --- a/homeassistant/components/aemet/config_flow.py +++ b/homeassistant/components/aemet/config_flow.py @@ -7,10 +7,9 @@ from aemet_opendata.exceptions import AuthError from aemet_opendata.interface import AEMET, ConnectionOptions import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME 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.schema_config_entry_flow import ( SchemaFlowFormStep, @@ -29,12 +28,12 @@ OPTIONS_FLOW = { } -class AemetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AemetConfigFlow(ConfigFlow, domain=DOMAIN): """Config flow for AEMET OpenData.""" async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" errors = {} @@ -75,7 +74,7 @@ class AemetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> SchemaOptionsFlowHandler: """Get the options flow for this handler.""" return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) diff --git a/homeassistant/components/aftership/config_flow.py b/homeassistant/components/aftership/config_flow.py index 94578091501..9d377ae8ce7 100644 --- a/homeassistant/components/aftership/config_flow.py +++ b/homeassistant/components/aftership/config_flow.py @@ -7,10 +7,9 @@ from typing import Any from pyaftership import AfterShip, AfterShipException import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_NAME from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue @@ -26,7 +25,7 @@ class AfterShipConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: @@ -49,7 +48,7 @@ class AfterShipConfigFlow(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_import(self, config: dict[str, Any]) -> FlowResult: + async def async_step_import(self, config: dict[str, Any]) -> ConfigFlowResult: """Import configuration from yaml.""" async_create_issue( self.hass, diff --git a/homeassistant/components/agent_dvr/config_flow.py b/homeassistant/components/agent_dvr/config_flow.py index 9143d40352f..065209e8199 100644 --- a/homeassistant/components/agent_dvr/config_flow.py +++ b/homeassistant/components/agent_dvr/config_flow.py @@ -6,9 +6,8 @@ from agent import AgentConnectionError, AgentError from agent.a import Agent import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN, SERVER_URL @@ -17,12 +16,12 @@ from .helpers import generate_url DEFAULT_PORT = 8090 -class AgentFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AgentFlowHandler(ConfigFlow, domain=DOMAIN): """Handle an Agent config flow.""" async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle an Agent config flow.""" errors = {} diff --git a/homeassistant/components/airly/config_flow.py b/homeassistant/components/airly/config_flow.py index 27c7b0f91e3..3fd27d76c60 100644 --- a/homeassistant/components/airly/config_flow.py +++ b/homeassistant/components/airly/config_flow.py @@ -10,23 +10,22 @@ from airly import Airly from airly.exceptions import AirlyError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from .const import CONF_USE_NEAREST, DOMAIN, NO_AIRLY_SENSORS -class AirlyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AirlyFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Airly.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" errors = {} use_nearest = False diff --git a/homeassistant/components/airnow/config_flow.py b/homeassistant/components/airnow/config_flow.py index a6fa7aa5088..e6ffbf1931a 100644 --- a/homeassistant/components/airnow/config_flow.py +++ b/homeassistant/components/airnow/config_flow.py @@ -6,16 +6,15 @@ from pyairnow import WebServiceAPI from pyairnow.errors import AirNowError, EmptyResponseError, InvalidKeyError import voluptuous as vol -from homeassistant import core from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, + ConfigFlowResult, OptionsFlow, OptionsFlowWithConfigEntry, ) from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS -from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv @@ -62,7 +61,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} if user_input is not None: @@ -117,7 +116,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN): ) @staticmethod - @core.callback + @callback def async_get_options_flow( config_entry: ConfigEntry, ) -> OptionsFlow: @@ -130,7 +129,7 @@ class AirNowOptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: return self.async_create_entry(data=user_input) diff --git a/homeassistant/components/airq/config_flow.py b/homeassistant/components/airq/config_flow.py index 33d76ec75bc..b260c372efc 100644 --- a/homeassistant/components/airq/config_flow.py +++ b/homeassistant/components/airq/config_flow.py @@ -8,9 +8,8 @@ from aioairq import AirQ, InvalidAuth from aiohttp.client_exceptions import ClientConnectionError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -25,14 +24,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AirQConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for air-Q.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial (authentication) configuration step.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/airthings/config_flow.py b/homeassistant/components/airthings/config_flow.py index 62f66213a0f..e5c800dfb55 100644 --- a/homeassistant/components/airthings/config_flow.py +++ b/homeassistant/components/airthings/config_flow.py @@ -7,9 +7,8 @@ from typing import Any import airthings import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ID -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import CONF_SECRET, DOMAIN @@ -24,14 +23,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Airthings.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/airthings_ble/config_flow.py b/homeassistant/components/airthings_ble/config_flow.py index 4228fea50d7..5f08f198761 100644 --- a/homeassistant/components/airthings_ble/config_flow.py +++ b/homeassistant/components/airthings_ble/config_flow.py @@ -15,9 +15,8 @@ from homeassistant.components.bluetooth import ( BluetoothServiceInfo, async_discovered_service_info, ) -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN, MFCT_ID @@ -93,7 +92,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the bluetooth discovery step.""" _LOGGER.debug("Discovered BT device: %s", discovery_info) await self.async_set_unique_id(discovery_info.address) @@ -114,7 +113,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" if user_input is not None: return self.async_create_entry( @@ -129,7 +128,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user step to pick discovered device.""" if user_input is not None: address = user_input[CONF_ADDRESS] diff --git a/homeassistant/components/airtouch4/config_flow.py b/homeassistant/components/airtouch4/config_flow.py index e395c71349b..18050308cc0 100644 --- a/homeassistant/components/airtouch4/config_flow.py +++ b/homeassistant/components/airtouch4/config_flow.py @@ -2,7 +2,7 @@ from airtouch4pyapi import AirTouch, AirTouchStatus import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow from homeassistant.const import CONF_HOST from .const import DOMAIN @@ -10,7 +10,7 @@ from .const import DOMAIN DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str}) -class AirtouchConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AirtouchConfigFlow(ConfigFlow, domain=DOMAIN): """Handle an Airtouch config flow.""" VERSION = 1 diff --git a/homeassistant/components/airtouch5/config_flow.py b/homeassistant/components/airtouch5/config_flow.py index e5df2844653..4f3b69de42c 100644 --- a/homeassistant/components/airtouch5/config_flow.py +++ b/homeassistant/components/airtouch5/config_flow.py @@ -9,7 +9,6 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_HOST -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -25,7 +24,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> config_entries.ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] | None = None if user_input is not None: diff --git a/homeassistant/components/airvisual/config_flow.py b/homeassistant/components/airvisual/config_flow.py index 23a26e2cca6..6cea9499314 100644 --- a/homeassistant/components/airvisual/config_flow.py +++ b/homeassistant/components/airvisual/config_flow.py @@ -15,8 +15,7 @@ from pyairvisual.cloud_api import ( from pyairvisual.errors import AirVisualError import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_API_KEY, CONF_COUNTRY, @@ -26,7 +25,6 @@ from homeassistant.const import ( CONF_STATE, ) 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.schema_config_entry_flow import ( SchemaFlowFormStep, @@ -70,7 +68,7 @@ OPTIONS_FLOW = { } -class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AirVisualFlowHandler(ConfigFlow, domain=DOMAIN): """Handle an AirVisual config flow.""" VERSION = 3 @@ -96,7 +94,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def _async_finish_geography( self, user_input: dict[str, str], integration_type: str - ) -> FlowResult: + ) -> ConfigFlowResult: """Validate a Cloud API key.""" errors = {} websession = aiohttp_client.async_get_clientsession(self.hass) @@ -155,7 +153,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def _async_init_geography( self, user_input: dict[str, str], integration_type: str - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initialization of the integration via the cloud API.""" self._geo_id = async_get_geography_id(user_input) await self._async_set_unique_id(self._geo_id) @@ -173,7 +171,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Define the config flow to handle options.""" return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) - async def async_step_import(self, import_data: dict[str, str]) -> FlowResult: + async def async_step_import(self, import_data: dict[str, str]) -> ConfigFlowResult: """Handle import of config entry version 1 data.""" import_source = import_data.pop("import_source") if import_source == "geography_by_coords": @@ -182,7 +180,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_geography_by_coords( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initialization of the cloud API based on latitude/longitude.""" if not user_input: return self.async_show_form( @@ -195,7 +193,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_geography_by_name( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initialization of the cloud API based on city/state/country.""" if not user_input: return self.async_show_form( @@ -206,7 +204,9 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): user_input, INTEGRATION_TYPE_GEOGRAPHY_NAME ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self._entry_data_for_reauth = entry_data self._geo_id = async_get_geography_id(entry_data) @@ -214,7 +214,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle re-auth completion.""" if not user_input: return self.async_show_form( @@ -229,7 +229,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the start of the config flow.""" if not user_input: return self.async_show_form( diff --git a/homeassistant/components/airvisual_pro/config_flow.py b/homeassistant/components/airvisual_pro/config_flow.py index 23da39150c5..af362c7318e 100644 --- a/homeassistant/components/airvisual_pro/config_flow.py +++ b/homeassistant/components/airvisual_pro/config_flow.py @@ -13,10 +13,8 @@ from pyairvisual.node import ( ) import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN, LOGGER @@ -72,7 +70,7 @@ async def async_validate_credentials( return ValidationResult(errors=errors) -class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AirVisualProFlowHandler(ConfigFlow, domain=DOMAIN): """Handle an AirVisual Pro config flow.""" VERSION = 1 @@ -81,11 +79,15 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Initialize.""" self._reauth_entry: ConfigEntry | None = None - async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult: + async def async_step_import( + self, import_config: dict[str, Any] + ) -> ConfigFlowResult: """Import a config entry from configuration.yaml.""" return await self.async_step_user(import_config) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -94,7 +96,7 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the re-auth step.""" if user_input is None: return self.async_show_form( @@ -124,7 +126,7 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if not user_input: return self.async_show_form(step_id="user", data_schema=STEP_USER_SCHEMA) diff --git a/homeassistant/components/airzone/config_flow.py b/homeassistant/components/airzone/config_flow.py index 7a8fdbf884b..02a7a3f378a 100644 --- a/homeassistant/components/airzone/config_flow.py +++ b/homeassistant/components/airzone/config_flow.py @@ -9,10 +9,10 @@ from aioairzone.exceptions import AirzoneError, InvalidSystem from aioairzone.localapi import AirzoneLocalApi, ConnectionOptions import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import dhcp +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_ID, CONF_PORT -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from homeassistant.helpers import aiohttp_client from homeassistant.helpers.device_registry import format_mac @@ -38,7 +38,7 @@ def short_mac(addr: str) -> str: return addr.replace(":", "")[-4:].upper() -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AirZoneConfigFlow(ConfigFlow, domain=DOMAIN): """Handle config flow for an Airzone device.""" _discovered_ip: str | None = None @@ -46,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" data_schema = CONFIG_SCHEMA errors = {} @@ -91,7 +91,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Handle DHCP discovery.""" self._discovered_ip = discovery_info.ip self._discovered_mac = discovery_info.macaddress @@ -118,7 +120,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_discovered_connection( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" assert self._discovered_ip is not None assert self._discovered_mac is not None diff --git a/homeassistant/components/airzone_cloud/config_flow.py b/homeassistant/components/airzone_cloud/config_flow.py index 32274d4e8ef..e523ba23cbe 100644 --- a/homeassistant/components/airzone_cloud/config_flow.py +++ b/homeassistant/components/airzone_cloud/config_flow.py @@ -9,9 +9,8 @@ from aioairzone_cloud.const import AZD_ID, AZD_NAME, AZD_WEBSERVERS from aioairzone_cloud.exceptions import AirzoneCloudError, LoginError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from homeassistant.helpers.selector import ( SelectOptionDict, @@ -23,14 +22,14 @@ from homeassistant.helpers.selector import ( from .const import DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AirZoneCloudConfigFlow(ConfigFlow, domain=DOMAIN): """Handle config flow for an Airzone Cloud device.""" airzone: AirzoneCloudApi async def async_step_inst_pick( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the installation selection.""" errors = {} options: dict[str, str] = {} @@ -81,7 +80,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} diff --git a/homeassistant/components/aladdin_connect/config_flow.py b/homeassistant/components/aladdin_connect/config_flow.py index d14b7b7c35e..e3a6867445c 100644 --- a/homeassistant/components/aladdin_connect/config_flow.py +++ b/homeassistant/components/aladdin_connect/config_flow.py @@ -9,10 +9,9 @@ import AIOAladdinConnect.session_manager as Aladdin from aiohttp.client_exceptions import ClientError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -48,13 +47,15 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None: raise InvalidAuth from ex -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AladdinConnectConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Aladdin Connect.""" VERSION = 1 - entry: config_entries.ConfigEntry | None + entry: ConfigEntry | None - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle re-authentication with Aladdin Connect.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) @@ -62,7 +63,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm re-authentication with Aladdin Connect.""" errors: dict[str, str] = {} @@ -102,7 +103,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/alarmdecoder/config_flow.py b/homeassistant/components/alarmdecoder/config_flow.py index 1b2bcf083ba..0b1ebdf8af7 100644 --- a/homeassistant/components/alarmdecoder/config_flow.py +++ b/homeassistant/components/alarmdecoder/config_flow.py @@ -9,14 +9,17 @@ from alarmdecoder.devices import SerialDevice, SocketDevice from alarmdecoder.util import NoDeviceError import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.binary_sensor import ( DEVICE_CLASSES_SCHEMA as BINARY_SENSOR_DEVICE_CLASSES_SCHEMA, ) -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_HOST, CONF_PORT, CONF_PROTOCOL from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import ( CONF_ALT_NIGHT_MODE, @@ -52,7 +55,7 @@ EDIT_SETTINGS = "Arming Settings" _LOGGER = logging.getLogger(__name__) -class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AlarmDecoderFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a AlarmDecoder config flow.""" VERSION = 1 @@ -64,14 +67,14 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> AlarmDecoderOptionsFlowHandler: """Get the options flow for AlarmDecoder.""" return AlarmDecoderOptionsFlowHandler(config_entry) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if user_input is not None: self.protocol = user_input[CONF_PROTOCOL] @@ -90,7 +93,7 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_protocol( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle AlarmDecoder protocol setup.""" errors = {} if user_input is not None: @@ -150,12 +153,12 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) -class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow): +class AlarmDecoderOptionsFlowHandler(OptionsFlow): """Handle AlarmDecoder options.""" selected_zone: str | None = None - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize AlarmDecoder options flow.""" self.arm_options = config_entry.options.get(OPTIONS_ARM, DEFAULT_ARM_OPTIONS) self.zone_options = config_entry.options.get( @@ -164,7 +167,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: if user_input[EDIT_KEY] == EDIT_SETTINGS: @@ -185,7 +188,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow): async def async_step_arm_settings( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Arming options form.""" if user_input is not None: return self.async_create_entry( @@ -214,7 +217,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow): async def async_step_zone_select( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Zone selection form.""" errors = _validate_zone_input(user_input) @@ -232,7 +235,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow): async def async_step_zone_details( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Zone details form.""" errors = _validate_zone_input(user_input) diff --git a/homeassistant/components/amberelectric/config_flow.py b/homeassistant/components/amberelectric/config_flow.py index 765e219b6d7..ee94f445498 100644 --- a/homeassistant/components/amberelectric/config_flow.py +++ b/homeassistant/components/amberelectric/config_flow.py @@ -6,9 +6,8 @@ from amberelectric.api import amber_api from amberelectric.model.site import Site, SiteStatus import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_TOKEN -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.selector import ( SelectOptionDict, SelectSelector, @@ -43,7 +42,7 @@ def filter_sites(sites: list[Site]) -> list[Site]: return filtered -class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AmberElectricConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 @@ -73,7 +72,7 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when user initializes a integration.""" self._errors = {} self._sites = None @@ -107,7 +106,7 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_site( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step to select site.""" self._errors = {} diff --git a/homeassistant/components/ambiclimate/config_flow.py b/homeassistant/components/ambiclimate/config_flow.py index 383a11055e4..598a8748412 100644 --- a/homeassistant/components/ambiclimate/config_flow.py +++ b/homeassistant/components/ambiclimate/config_flow.py @@ -5,11 +5,10 @@ from typing import Any from aiohttp import web import ambiclimate -from homeassistant import config_entries from homeassistant.components.http import HomeAssistantView +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.network import get_url from homeassistant.helpers.storage import Store @@ -44,7 +43,7 @@ def register_flow_implementation( } -class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AmbiclimateFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 @@ -56,7 +55,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle external yaml configuration.""" self._async_abort_entries_match() @@ -70,7 +69,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_auth( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow start.""" self._async_abort_entries_match() @@ -91,7 +90,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_code(self, code: str | None = None) -> FlowResult: + async def async_step_code(self, code: str | None = None) -> ConfigFlowResult: """Received code for authentication.""" self._async_abort_entries_match() diff --git a/homeassistant/components/ambient_station/config_flow.py b/homeassistant/components/ambient_station/config_flow.py index 2c2d231b33e..8e9ff87a5f6 100644 --- a/homeassistant/components/ambient_station/config_flow.py +++ b/homeassistant/components/ambient_station/config_flow.py @@ -5,15 +5,14 @@ from aioambient import API from aioambient.errors import AmbientError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from .const import CONF_APP_KEY, DOMAIN -class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AmbientStationFlowHandler(ConfigFlow, domain=DOMAIN): """Handle an Ambient PWS config flow.""" VERSION = 2 @@ -24,7 +23,7 @@ class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): {vol.Required(CONF_API_KEY): str, vol.Required(CONF_APP_KEY): str} ) - async def _show_form(self, errors: dict | None = None) -> FlowResult: + async def _show_form(self, errors: dict | None = None) -> ConfigFlowResult: """Show the form to the user.""" return self.async_show_form( step_id="user", @@ -32,7 +31,7 @@ class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors=errors if errors else {}, ) - async def async_step_user(self, user_input: dict | None = None) -> FlowResult: + async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult: """Handle the start of the config flow.""" if not user_input: return await self._show_form() diff --git a/homeassistant/components/analytics_insights/config_flow.py b/homeassistant/components/analytics_insights/config_flow.py index d2ebdd943a2..edc69a0d161 100644 --- a/homeassistant/components/analytics_insights/config_flow.py +++ b/homeassistant/components/analytics_insights/config_flow.py @@ -13,11 +13,11 @@ import voluptuous as vol from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, + ConfigFlowResult, OptionsFlow, OptionsFlowWithConfigEntry, ) from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.selector import ( SelectOptionDict, @@ -50,7 +50,7 @@ class HomeassistantAnalyticsConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" self._async_abort_entries_match() errors: dict[str, str] = {} @@ -120,7 +120,7 @@ class HomeassistantAnalyticsOptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/android_ip_webcam/config_flow.py b/homeassistant/components/android_ip_webcam/config_flow.py index 2a26292fdd7..920c9cdf702 100644 --- a/homeassistant/components/android_ip_webcam/config_flow.py +++ b/homeassistant/components/android_ip_webcam/config_flow.py @@ -7,10 +7,9 @@ from pydroid_ipcam import PyDroidIPCam from pydroid_ipcam.exceptions import PyDroidIPCamException, Unauthorized import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -50,14 +49,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, return errors -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AndroidIPWebcamConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Android IP Webcam.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/androidtv/config_flow.py b/homeassistant/components/androidtv/config_flow.py index e688b0a92de..5df4bf2f89b 100644 --- a/homeassistant/components/androidtv/config_flow.py +++ b/homeassistant/components/androidtv/config_flow.py @@ -11,11 +11,11 @@ import voluptuous as vol from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, + ConfigFlowResult, OptionsFlowWithConfigEntry, ) from homeassistant.const import CONF_DEVICE_CLASS, CONF_HOST, CONF_PORT from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from homeassistant.helpers.selector import ( ObjectSelector, @@ -81,7 +81,7 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None, error: str | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the setup form to the user.""" host = user_input.get(CONF_HOST, "") if user_input else "" data_schema = vol.Schema( @@ -144,7 +144,7 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" error = None @@ -199,7 +199,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): self._conf_rule_id: str | None = None @callback - def _save_config(self, data: dict[str, Any]) -> FlowResult: + def _save_config(self, data: dict[str, Any]) -> ConfigFlowResult: """Save the updated options.""" new_data = { k: v @@ -215,7 +215,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle options flow.""" if user_input is not None: if sel_app := user_input.get(CONF_APPS): @@ -227,7 +227,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): return self._async_init_form() @callback - def _async_init_form(self) -> FlowResult: + def _async_init_form(self) -> ConfigFlowResult: """Return initial configuration form.""" apps_list = {k: f"{v} ({k})" if v else k for k, v in self._apps.items()} @@ -280,7 +280,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_apps( self, user_input: dict[str, Any] | None = None, app_id: str | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle options flow for apps list.""" if app_id is not None: self._conf_app_id = app_id if app_id != APPS_NEW_ID else None @@ -297,7 +297,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): return await self.async_step_init() @callback - def _async_apps_form(self, app_id: str) -> FlowResult: + def _async_apps_form(self, app_id: str) -> ConfigFlowResult: """Return configuration form for apps.""" app_schema = { vol.Optional( @@ -322,7 +322,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_rules( self, user_input: dict[str, Any] | None = None, rule_id: str | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle options flow for detection rules.""" if rule_id is not None: self._conf_rule_id = rule_id if rule_id != RULES_NEW_ID else None @@ -348,7 +348,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry): @callback def _async_rules_form( self, rule_id: str, default_id: str = "", errors: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Return configuration form for detection rules.""" rule_schema = { vol.Optional( diff --git a/homeassistant/components/androidtv_remote/config_flow.py b/homeassistant/components/androidtv_remote/config_flow.py index 03e09c6ecb0..78f039d83fc 100644 --- a/homeassistant/components/androidtv_remote/config_flow.py +++ b/homeassistant/components/androidtv_remote/config_flow.py @@ -16,11 +16,11 @@ from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, + ConfigFlowResult, OptionsFlowWithConfigEntry, ) from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.device_registry import format_mac from .const import CONF_ENABLE_IME, DOMAIN @@ -54,7 +54,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: @@ -78,7 +78,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def _async_start_pair(self) -> FlowResult: + async def _async_start_pair(self) -> ConfigFlowResult: """Start pairing with the Android TV. Navigate to the pair flow to enter the PIN shown on screen.""" assert self.host self.api = create_api(self.hass, self.host, enable_ime=False) @@ -88,7 +88,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_pair( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the pair step.""" errors: dict[str, str] = {} if user_input is not None: @@ -136,7 +136,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.host = discovery_info.host self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.") @@ -152,7 +152,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by zeroconf.""" if user_input is not None: try: @@ -166,7 +166,9 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): description_placeholders={CONF_NAME: self.name}, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self.host = entry_data[CONF_HOST] self.name = entry_data[CONF_NAME] @@ -178,7 +180,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Dialog that informs the user that reauth is required.""" errors: dict[str, str] = {} if user_input is not None: @@ -207,7 +209,7 @@ class AndroidTVRemoteOptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/anova/config_flow.py b/homeassistant/components/anova/config_flow.py index d0846fbffc7..13f62451e19 100644 --- a/homeassistant/components/anova/config_flow.py +++ b/homeassistant/components/anova/config_flow.py @@ -4,9 +4,8 @@ from __future__ import annotations from anova_wifi import AnovaApi, InvalidLogin, NoDevicesFound import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -20,7 +19,7 @@ class AnovaConfligFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/anthemav/config_flow.py b/homeassistant/components/anthemav/config_flow.py index 892c40cde0e..51124451156 100644 --- a/homeassistant/components/anthemav/config_flow.py +++ b/homeassistant/components/anthemav/config_flow.py @@ -9,9 +9,8 @@ from anthemav.connection import Connection from anthemav.device_error import DeviceError import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MAC, CONF_MODEL, CONF_PORT -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from homeassistant.helpers.device_registry import format_mac @@ -44,7 +43,7 @@ class AnthemAVConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/aosmith/config_flow.py b/homeassistant/components/aosmith/config_flow.py index 899b7382359..65262890868 100644 --- a/homeassistant/components/aosmith/config_flow.py +++ b/homeassistant/components/aosmith/config_flow.py @@ -8,9 +8,8 @@ from typing import Any from py_aosmith import AOSmithAPIClient, AOSmithInvalidCredentialsException import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_EMAIL, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from .const import DOMAIN @@ -18,7 +17,7 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AOSmithConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for A. O. Smith.""" VERSION = 1 @@ -44,7 +43,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: @@ -73,14 +72,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth if the user credentials have changed.""" self._reauth_email = entry_data[CONF_EMAIL] return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user's reauth credentials.""" errors: dict[str, str] = {} if user_input is not None and self._reauth_email is not None: diff --git a/homeassistant/components/apcupsd/config_flow.py b/homeassistant/components/apcupsd/config_flow.py index 25a1ccf7e02..0e4c5ecb413 100644 --- a/homeassistant/components/apcupsd/config_flow.py +++ b/homeassistant/components/apcupsd/config_flow.py @@ -5,9 +5,8 @@ from typing import Any import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import selector import homeassistant.helpers.config_validation as cv from homeassistant.helpers.update_coordinator import UpdateFailed @@ -38,7 +37,7 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: diff --git a/homeassistant/components/apple_tv/config_flow.py b/homeassistant/components/apple_tv/config_flow.py index 2bb4608dca1..bd95aa6ca39 100644 --- a/homeassistant/components/apple_tv/config_flow.py +++ b/homeassistant/components/apple_tv/config_flow.py @@ -16,11 +16,17 @@ from pyatv.helpers import get_unique_id from pyatv.interface import BaseConfig, PairingHandler import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf +from homeassistant.config_entries import ( + SOURCE_IGNORE, + SOURCE_ZEROCONF, + ConfigEntry, + ConfigFlow, + ConfigFlowResult, +) from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_PIN from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.schema_config_entry_flow import ( @@ -85,7 +91,7 @@ async def device_scan( return None, None -class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Apple TV.""" VERSION = 1 @@ -100,7 +106,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> SchemaOptionsFlowHandler: """Get options flow for this handler.""" return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) @@ -141,7 +147,9 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return entry.unique_id return None - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle initial step when updating invalid credentials.""" self.context["title_placeholders"] = { "name": entry_data[CONF_NAME], @@ -153,7 +161,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reconfigure( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Inform user that reconfiguration is about to start.""" if user_input is not None: return await self.async_find_device_wrapper( @@ -164,7 +172,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} if user_input is not None: @@ -194,7 +202,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle device found via zeroconf.""" if discovery_info.ip_address.version == 6: return self.async_abort(reason="ipv6_not_supported") @@ -276,7 +284,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): for flow in self._async_in_progress(include_uninitialized=True): context = flow["context"] if ( - context.get("source") != config_entries.SOURCE_ZEROCONF + context.get("source") != SOURCE_ZEROCONF or context.get(CONF_ADDRESS) != host ): continue @@ -290,7 +298,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_found_zeroconf_device( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle device found after Zeroconf discovery.""" assert self.atv self.context["all_identifiers"] = self.atv.all_identifiers @@ -306,9 +314,9 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_find_device_wrapper( self, - next_func: Callable[[], Awaitable[FlowResult]], + next_func: Callable[[], Awaitable[ConfigFlowResult]], allow_exist: bool = False, - ) -> FlowResult: + ) -> ConfigFlowResult: """Find a specific device and call another function when done. This function will do error handling and bail out when an error @@ -370,7 +378,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): CONF_IDENTIFIERS: list(combined_identifiers), }, ) - if entry.source != config_entries.SOURCE_IGNORE: + if entry.source != SOURCE_IGNORE: self.hass.async_create_task( self.hass.config_entries.async_reload(entry.entry_id) ) @@ -379,7 +387,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user-confirmation of discovered node.""" assert self.atv if user_input is not None: @@ -407,7 +415,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): }, ) - async def async_pair_next_protocol(self) -> FlowResult: + async def async_pair_next_protocol(self) -> ConfigFlowResult: """Start pairing process for the next available protocol.""" await self._async_cleanup() @@ -481,7 +489,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_protocol_disabled( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Inform user that a protocol is disabled and cannot be paired.""" assert self.protocol if user_input is not None: @@ -493,7 +501,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_pair_with_pin( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle pairing step where a PIN is required from the user.""" errors = {} assert self.pairing @@ -520,7 +528,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_pair_no_pin( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle step where user has to enter a PIN on the device.""" assert self.pairing assert self.protocol @@ -545,7 +553,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_service_problem( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Inform user that a service will not be added.""" assert self.protocol if user_input is not None: @@ -558,7 +566,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_password( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Inform user that password is not supported.""" assert self.protocol if user_input is not None: @@ -575,7 +583,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): await self.pairing.close() self.pairing = None - async def _async_get_entry(self) -> FlowResult: + async def _async_get_entry(self) -> ConfigFlowResult: """Return config entry or update existing config entry.""" # Abort if no protocols were paired if not self.credentials: diff --git a/homeassistant/components/aprilaire/config_flow.py b/homeassistant/components/aprilaire/config_flow.py index 0e38b385450..14437e5f3f2 100644 --- a/homeassistant/components/aprilaire/config_flow.py +++ b/homeassistant/components/aprilaire/config_flow.py @@ -10,7 +10,6 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from homeassistant.helpers.device_registry import format_mac @@ -34,7 +33,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> config_entries.ConfigFlowResult: """Handle the initial step.""" if user_input is None: diff --git a/homeassistant/components/aranet/config_flow.py b/homeassistant/components/aranet/config_flow.py index 029ee251ae7..8d813884a82 100644 --- a/homeassistant/components/aranet/config_flow.py +++ b/homeassistant/components/aranet/config_flow.py @@ -7,13 +7,13 @@ from typing import Any from aranet4.client import Aranet4Advertisement, Version as AranetVersion import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.bluetooth import ( BluetoothServiceInfoBleak, async_discovered_service_info, ) +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from .const import DOMAIN @@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__) MIN_VERSION = AranetVersion(1, 2, 0) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AranetConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Aranet.""" VERSION = 1 @@ -45,7 +45,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the Bluetooth discovery step.""" await self.async_set_unique_id(discovery_info.address) self._abort_if_unique_id_configured() @@ -58,7 +58,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" assert self._discovered_device is not None adv = self._discovered_device @@ -77,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user step to pick discovered device.""" if user_input is not None: address = user_input[CONF_ADDRESS] diff --git a/homeassistant/components/arcam_fmj/config_flow.py b/homeassistant/components/arcam_fmj/config_flow.py index 09944328c4a..481657bcd85 100644 --- a/homeassistant/components/arcam_fmj/config_flow.py +++ b/homeassistant/components/arcam_fmj/config_flow.py @@ -8,23 +8,22 @@ from arcam.fmj.client import Client, ConnectionFailed from arcam.fmj.utils import get_uniqueid_from_host, get_uniqueid_from_udn import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DEFAULT_NAME, DEFAULT_PORT, DOMAIN, DOMAIN_DATA_ENTRIES -def get_entry_client(hass: HomeAssistant, entry: config_entries.ConfigEntry) -> Client: +def get_entry_client(hass: HomeAssistant, entry: ConfigEntry) -> Client: """Retrieve client associated with a config entry.""" client: Client = hass.data[DOMAIN_DATA_ENTRIES][entry.entry_id] return client -class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class ArcamFmjFlowHandler(ConfigFlow, domain=DOMAIN): """Handle config flow.""" VERSION = 1 @@ -35,7 +34,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(uuid) self._abort_if_unique_id_configured({CONF_HOST: host, CONF_PORT: port}) - async def _async_check_and_create(self, host: str, port: int) -> FlowResult: + async def _async_check_and_create(self, host: str, port: int) -> ConfigFlowResult: client = Client(host, port) try: await client.start() @@ -51,7 +50,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a discovered device.""" errors: dict[str, str] = {} @@ -79,7 +78,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user-confirmation of discovered node.""" context = self.context placeholders = { @@ -96,7 +95,9 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): step_id="confirm", description_placeholders=placeholders ) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a discovered device.""" host = str(urlparse(discovery_info.ssdp_location).hostname) port = DEFAULT_PORT diff --git a/homeassistant/components/aseko_pool_live/config_flow.py b/homeassistant/components/aseko_pool_live/config_flow.py index c8f96db3bc8..ef9ea9ef29e 100644 --- a/homeassistant/components/aseko_pool_live/config_flow.py +++ b/homeassistant/components/aseko_pool_live/config_flow.py @@ -7,14 +7,13 @@ from typing import Any from aioaseko import APIUnavailable, InvalidAuthCredentials, MobileAccount, WebAccount import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_ACCESS_TOKEN, CONF_EMAIL, CONF_PASSWORD, CONF_UNIQUE_ID, ) -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -22,7 +21,7 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AsekoConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Aseko Pool Live.""" VERSION = 1 @@ -45,7 +44,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} if user_input is not None: diff --git a/homeassistant/components/asuswrt/config_flow.py b/homeassistant/components/asuswrt/config_flow.py index 1e320bdd72d..e456b1c55ba 100644 --- a/homeassistant/components/asuswrt/config_flow.py +++ b/homeassistant/components/asuswrt/config_flow.py @@ -14,7 +14,7 @@ from homeassistant.components.device_tracker import ( CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME, ) -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_BASE, CONF_HOST, @@ -25,7 +25,6 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from homeassistant.helpers.schema_config_entry_flow import ( SchemaCommonFlowHandler, @@ -139,7 +138,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN): self._config_data: dict[str, Any] = {} @callback - def _show_setup_form(self, error: str | None = None) -> FlowResult: + def _show_setup_form(self, error: str | None = None) -> ConfigFlowResult: """Show the setup form to the user.""" user_input = self._config_data @@ -228,7 +227,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" # if there's one entry without unique ID, we abort config flow @@ -276,7 +275,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_legacy( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow for legacy settings.""" if user_input is None: return self.async_show_form(step_id="legacy", data_schema=LEGACY_SCHEMA) @@ -284,7 +283,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN): self._config_data.update(user_input) return await self._async_save_entry() - async def _async_save_entry(self) -> FlowResult: + async def _async_save_entry(self) -> ConfigFlowResult: """Save entry data if unique id is valid.""" return self.async_create_entry( title=self._config_data[CONF_HOST], diff --git a/homeassistant/components/atag/config_flow.py b/homeassistant/components/atag/config_flow.py index 8dd7020acfb..f4e60bc6062 100644 --- a/homeassistant/components/atag/config_flow.py +++ b/homeassistant/components/atag/config_flow.py @@ -4,9 +4,8 @@ from typing import Any import pyatag import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from . import DOMAIN @@ -17,14 +16,14 @@ DATA_SCHEMA = { } -class AtagConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AtagConfigFlow(ConfigFlow, domain=DOMAIN): """Config flow for Atag.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if not user_input: @@ -44,7 +43,9 @@ class AtagConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_create_entry(title=atag.id, data=user_input) - async def _show_form(self, errors: dict[str, str] | None = None) -> FlowResult: + async def _show_form( + self, errors: dict[str, str] | None = None + ) -> ConfigFlowResult: """Show the form to the user.""" return self.async_show_form( step_id="user", diff --git a/homeassistant/components/august/config_flow.py b/homeassistant/components/august/config_flow.py index 8aaf1b1a05b..3c0208412b9 100644 --- a/homeassistant/components/august/config_flow.py +++ b/homeassistant/components/august/config_flow.py @@ -9,10 +9,9 @@ import voluptuous as vol from yalexs.authenticator import ValidationResult from yalexs.const import BRANDS, DEFAULT_BRAND -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import ( CONF_ACCESS_TOKEN_CACHE_FILE, @@ -75,7 +74,7 @@ class ValidateResult: description_placeholders: dict[str, str] -class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AugustConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for August.""" VERSION = 1 @@ -91,13 +90,13 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" return await self.async_step_user_validate() async def async_step_user_validate( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle authentication.""" errors: dict[str, str] = {} description_placeholders: dict[str, str] = {} @@ -137,7 +136,7 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_validation( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle validation (2fa) step.""" if user_input: if self._mode == "reauth": @@ -174,7 +173,9 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._aiohttp_session.detach() self._august_gateway = None - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self._user_auth_details = dict(entry_data) self._mode = "reauth" @@ -183,7 +184,7 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_validate( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle reauth and validation.""" errors: dict[str, str] = {} description_placeholders: dict[str, str] = {} @@ -261,7 +262,9 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): validation_required, info, errors, description_placeholders ) - async def _async_update_or_create_entry(self, info: dict[str, Any]) -> FlowResult: + async def _async_update_or_create_entry( + self, info: dict[str, Any] + ) -> ConfigFlowResult: """Update existing entry or create a new one.""" self._async_shutdown_gateway() diff --git a/homeassistant/components/aurora/config_flow.py b/homeassistant/components/aurora/config_flow.py index a1971884ead..81e67acc27a 100644 --- a/homeassistant/components/aurora/config_flow.py +++ b/homeassistant/components/aurora/config_flow.py @@ -8,10 +8,9 @@ from aiohttp import ClientError from auroranoaa import AuroraForecast import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE 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.schema_config_entry_flow import ( SchemaFlowFormStep, @@ -34,7 +33,7 @@ OPTIONS_FLOW = { } -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AuroraConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for NOAA Aurora Integration.""" VERSION = 1 @@ -42,14 +41,14 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> SchemaOptionsFlowHandler: """Get the options flow for this handler.""" return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/aurora_abb_powerone/config_flow.py b/homeassistant/components/aurora_abb_powerone/config_flow.py index 32295c3bf47..37d802502bb 100644 --- a/homeassistant/components/aurora_abb_powerone/config_flow.py +++ b/homeassistant/components/aurora_abb_powerone/config_flow.py @@ -9,9 +9,9 @@ from aurorapy.client import AuroraError, AuroraSerialClient import serial.tools.list_ports import voluptuous as vol -from homeassistant import config_entries, core +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ATTR_SERIAL_NUMBER, CONF_ADDRESS, CONF_PORT -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant from .const import ( ATTR_FIRMWARE, @@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__) def validate_and_connect( - hass: core.HomeAssistant, data: Mapping[str, Any] + hass: HomeAssistant, data: Mapping[str, Any] ) -> dict[str, str]: """Validate the user input allows us to connect. @@ -69,7 +69,7 @@ def scan_comports() -> tuple[list[str] | None, str | None]: return None, None -class AuroraABBConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AuroraABBConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Aurora ABB PowerOne.""" VERSION = 1 @@ -82,7 +82,7 @@ class AuroraABBConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialised by the user.""" errors = {} diff --git a/homeassistant/components/aussie_broadband/config_flow.py b/homeassistant/components/aussie_broadband/config_flow.py index c71570b73fb..dedab9684e6 100644 --- a/homeassistant/components/aussie_broadband/config_flow.py +++ b/homeassistant/components/aussie_broadband/config_flow.py @@ -9,15 +9,14 @@ from aussiebb.asyncio import AussieBB, AuthenticationException from aussiebb.const import FETCH_TYPES import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import CONF_SERVICES, DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AussieBroadbandConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Aussie Broadband.""" VERSION = 1 @@ -47,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] | None = None if user_input is not None: @@ -77,7 +76,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauth on credential failure.""" self._reauth_username = entry_data[CONF_USERNAME] @@ -85,7 +86,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle users reauth credentials.""" errors: dict[str, str] | None = None diff --git a/homeassistant/components/awair/config_flow.py b/homeassistant/components/awair/config_flow.py index c68d46f7d39..751bcf6847d 100644 --- a/homeassistant/components/awair/config_flow.py +++ b/homeassistant/components/awair/config_flow.py @@ -11,10 +11,9 @@ from python_awair.user import AwairUser import voluptuous as vol from homeassistant.components import onboarding, zeroconf -from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow +from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ACCESS_TOKEN, CONF_DEVICE, CONF_HOST from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN, LOGGER @@ -29,7 +28,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.host @@ -58,7 +57,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_discovery_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" if user_input is not None or not onboarding.async_is_onboarded(self.hass): title = f"{self._device.model} ({self._device.device_id})" @@ -79,12 +78,12 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" return self.async_show_menu(step_id="user", menu_options=["local", "cloud"]) - async def async_step_cloud(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_cloud(self, user_input: Mapping[str, Any]) -> ConfigFlowResult: """Handle collecting and verifying Awair Cloud API credentials.""" errors = {} @@ -129,7 +128,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_local( self, user_input: Mapping[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show how to enable local API.""" if user_input is not None: return await self.async_step_local_pick() @@ -143,7 +142,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_local_pick( self, user_input: Mapping[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle collecting and verifying Awair Local API hosts.""" errors = {} @@ -188,13 +187,15 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle re-auth if token invalid.""" return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm reauth dialog.""" errors = {} diff --git a/homeassistant/components/aws/config_flow.py b/homeassistant/components/aws/config_flow.py index e0829ef2914..8c80b0d487d 100644 --- a/homeassistant/components/aws/config_flow.py +++ b/homeassistant/components/aws/config_flow.py @@ -3,18 +3,19 @@ from collections.abc import Mapping from typing import Any -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from .const import DOMAIN -class AWSFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AWSFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 - async def async_step_import(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_import( + self, user_input: Mapping[str, Any] + ) -> ConfigFlowResult: """Import a config entry.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index cbba23b8b51..1a46388dbd5 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -9,9 +9,14 @@ from urllib.parse import urlsplit import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import dhcp, ssdp, zeroconf -from homeassistant.config_entries import SOURCE_IGNORE, ConfigEntry +from homeassistant.config_entries import ( + SOURCE_IGNORE, + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlowWithConfigEntry, +) from homeassistant.const import ( CONF_HOST, CONF_MAC, @@ -22,7 +27,6 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.device_registry import format_mac from homeassistant.util.network import is_link_local @@ -40,7 +44,7 @@ AXIS_OUI = {"00:40:8c", "ac:cc:8e", "b8:a4:4f"} DEFAULT_PORT = 80 -class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): +class AxisFlowHandler(ConfigFlow, domain=AXIS_DOMAIN): """Handle a Axis config flow.""" VERSION = 3 @@ -58,7 +62,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a Axis config flow start. Manage device specific parameters. @@ -111,7 +115,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): errors=errors, ) - async def _create_entry(self, serial: str) -> FlowResult: + async def _create_entry(self, serial: str) -> ConfigFlowResult: """Create entry for device. Generate a name to be used as a prefix for device entities. @@ -134,7 +138,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): title = f"{model} - {serial}" return self.async_create_entry(title=title, data=self.device_config) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Trigger a reauthentication flow.""" self.context["title_placeholders"] = { CONF_NAME: entry_data[CONF_NAME], @@ -150,7 +156,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): return await self.async_step_user() - async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Prepare configuration for a DHCP discovered Axis device.""" return await self._process_discovered_device( { @@ -161,7 +169,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): } ) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Prepare configuration for a SSDP discovered Axis device.""" url = urlsplit(discovery_info.upnp[ssdp.ATTR_UPNP_PRESENTATION_URL]) return await self._process_discovered_device( @@ -175,7 +185,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Prepare configuration for a Zeroconf discovered Axis device.""" return await self._process_discovered_device( { @@ -186,7 +196,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): } ) - async def _process_discovered_device(self, device: dict[str, Any]) -> FlowResult: + async def _process_discovered_device( + self, device: dict[str, Any] + ) -> ConfigFlowResult: """Prepare configuration for a discovered Axis device.""" if device[CONF_MAC][:8] not in AXIS_OUI: return self.async_abort(reason="not_axis_device") @@ -223,21 +235,21 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): return await self.async_step_user() -class AxisOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry): +class AxisOptionsFlowHandler(OptionsFlowWithConfigEntry): """Handle Axis device options.""" device: AxisNetworkDevice async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the Axis device options.""" self.device = self.hass.data[AXIS_DOMAIN][self.config_entry.entry_id] return await self.async_step_configure_stream() async def async_step_configure_stream( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the Axis device stream options.""" if user_input is not None: self.options.update(user_input) diff --git a/homeassistant/components/azure_devops/config_flow.py b/homeassistant/components/azure_devops/config_flow.py index 81cfc2e8d45..4b7320eeba5 100644 --- a/homeassistant/components/azure_devops/config_flow.py +++ b/homeassistant/components/azure_devops/config_flow.py @@ -8,8 +8,7 @@ from aioazuredevops.client import DevOpsClient import aiohttp import voluptuous as vol -from homeassistant.config_entries import ConfigFlow -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN @@ -27,7 +26,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): async def _show_setup_form( self, errors: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the setup form to the user.""" return self.async_show_form( step_id="user", @@ -41,7 +40,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): errors=errors or {}, ) - async def _show_reauth_form(self, errors: dict[str, str]) -> FlowResult: + async def _show_reauth_form(self, errors: dict[str, str]) -> ConfigFlowResult: """Show the reauth form to the user.""" return self.async_show_form( step_id="reauth", @@ -75,7 +74,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if user_input is None: return await self._show_setup_form() @@ -92,7 +91,9 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): return await self._show_setup_form(errors) return self._async_create_entry() - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" if entry_data.get(CONF_ORG) and entry_data.get(CONF_PROJECT): self._organization = entry_data[CONF_ORG] @@ -121,7 +122,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): ) return self.async_abort(reason="reauth_successful") - def _async_create_entry(self) -> FlowResult: + def _async_create_entry(self) -> ConfigFlowResult: """Handle create entry.""" return self.async_create_entry( title=f"{self._organization}/{self._project}", diff --git a/homeassistant/components/azure_event_hub/config_flow.py b/homeassistant/components/azure_event_hub/config_flow.py index 3573d5e72aa..17144da0b30 100644 --- a/homeassistant/components/azure_event_hub/config_flow.py +++ b/homeassistant/components/azure_event_hub/config_flow.py @@ -8,9 +8,8 @@ from typing import Any from azure.eventhub.exceptions import EventHubError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.schema_config_entry_flow import ( SchemaFlowFormStep, SchemaOptionsFlowHandler, @@ -79,7 +78,7 @@ async def validate_data(data: dict[str, Any]) -> dict[str, str] | None: return None -class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class AEHConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for azure event hub.""" VERSION: int = 1 @@ -93,14 +92,14 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> SchemaOptionsFlowHandler: """Get the options flow for this handler.""" return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial user step.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -116,7 +115,7 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_conn_string( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the connection string steps.""" errors = await self.async_update_and_validate_data(user_input) if user_input is None or errors is not None: @@ -136,7 +135,7 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_sas( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the sas steps.""" errors = await self.async_update_and_validate_data(user_input) if user_input is None or errors is not None: @@ -154,7 +153,9 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): options=self._options, ) - async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult: + async def async_step_import( + self, import_config: dict[str, Any] + ) -> ConfigFlowResult: """Import config from configuration.yaml.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/baf/config_flow.py b/homeassistant/components/baf/config_flow.py index 0aaf2189c28..d5ac869526e 100644 --- a/homeassistant/components/baf/config_flow.py +++ b/homeassistant/components/baf/config_flow.py @@ -9,10 +9,9 @@ from aiobafi6 import Device, Service from aiobafi6.discovery import PORT import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN, RUN_TIMEOUT from .models import BAFDiscovery @@ -34,7 +33,7 @@ async def async_try_connect(ip_address: str) -> Device: return device -class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class BAFFlowHandler(ConfigFlow, domain=DOMAIN): """Handle BAF discovery config flow.""" VERSION = 1 @@ -45,7 +44,7 @@ class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" if discovery_info.ip_address.version == 6: return self.async_abort(reason="ipv6_not_supported") @@ -61,7 +60,7 @@ class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_discovery_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" assert self.discovery is not None discovery = self.discovery @@ -83,7 +82,7 @@ class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} ip_address = (user_input or {}).get(CONF_IP_ADDRESS, "") diff --git a/homeassistant/components/balboa/config_flow.py b/homeassistant/components/balboa/config_flow.py index 73f19f0e327..7705695f538 100644 --- a/homeassistant/components/balboa/config_flow.py +++ b/homeassistant/components/balboa/config_flow.py @@ -8,11 +8,10 @@ from pybalboa import SpaClient from pybalboa.exceptions import SpaConnectionError import voluptuous as vol -from homeassistant import exceptions -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.schema_config_entry_flow import ( SchemaFlowFormStep, @@ -65,7 +64,7 @@ class BalboaSpaClientFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" errors = {} if user_input is not None: @@ -87,5 +86,5 @@ class BalboaSpaClientFlowHandler(ConfigFlow, domain=DOMAIN): ) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" diff --git a/homeassistant/components/bang_olufsen/config_flow.py b/homeassistant/components/bang_olufsen/config_flow.py index 6a26c4c5984..73b6586adb9 100644 --- a/homeassistant/components/bang_olufsen/config_flow.py +++ b/homeassistant/components/bang_olufsen/config_flow.py @@ -10,9 +10,8 @@ from mozart_api.mozart_client import MozartClient import voluptuous as vol from homeassistant.components.zeroconf import ZeroconfServiceInfo -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MODEL -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig from .const import ( @@ -62,7 +61,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" data_schema = vol.Schema( { @@ -121,7 +120,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle discovery using Zeroconf.""" # Check if the discovered device is a Mozart device @@ -149,7 +148,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN): return await self.async_step_zeroconf_confirm() - async def _create_entry(self) -> FlowResult: + async def _create_entry(self) -> ConfigFlowResult: """Create the config entry for a discovered or manually configured Bang & Olufsen device.""" # Ensure that created entities have a unique and easily identifiable id and not a "friendly name" self._name = f"{self._model}-{self._serial_number}" @@ -166,7 +165,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm the configuration of the device.""" if user_input is not None: return await self._create_entry() diff --git a/homeassistant/components/blebox/config_flow.py b/homeassistant/components/blebox/config_flow.py index 977e704eb98..86b6380ff9f 100644 --- a/homeassistant/components/blebox/config_flow.py +++ b/homeassistant/components/blebox/config_flow.py @@ -14,10 +14,9 @@ from blebox_uniapi.error import ( from blebox_uniapi.session import ApiHost import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from . import get_maybe_authenticated_session @@ -65,7 +64,7 @@ LOG_MSG = { } -class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BleBoxConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for BleBox devices.""" VERSION = 1 @@ -89,7 +88,7 @@ class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" hass = self.hass ipaddress = (discovery_info.host, discovery_info.port) @@ -126,7 +125,7 @@ class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm_discovery( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle discovery confirmation.""" if user_input is not None: return self.async_create_entry( diff --git a/homeassistant/components/blink/config_flow.py b/homeassistant/components/blink/config_flow.py index aaacbb9390c..c49ef67be98 100644 --- a/homeassistant/components/blink/config_flow.py +++ b/homeassistant/components/blink/config_flow.py @@ -9,10 +9,9 @@ from blinkpy.auth import Auth, LoginError, TokenRefreshFailed from blinkpy.blinkpy import Blink, BlinkSetupError import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_PIN, CONF_USERNAME from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -51,7 +50,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" errors = {} if user_input is not None: @@ -86,7 +85,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_2fa( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle 2FA step.""" errors = {} if user_input is not None: @@ -113,12 +112,14 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth upon migration of old entries.""" return await self.async_step_user(dict(entry_data)) @callback - def _async_finish_flow(self) -> FlowResult: + def _async_finish_flow(self) -> ConfigFlowResult: """Finish with setup.""" assert self.auth return self.async_create_entry(title=DOMAIN, data=self.auth.login_attributes) diff --git a/homeassistant/components/blue_current/config_flow.py b/homeassistant/components/blue_current/config_flow.py index 68a30fcdf7f..56980649c0a 100644 --- a/homeassistant/components/blue_current/config_flow.py +++ b/homeassistant/components/blue_current/config_flow.py @@ -13,24 +13,23 @@ from bluecurrent_api.exceptions import ( ) import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_TOKEN -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN, LOGGER DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_TOKEN): str}) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN): """Handle the config flow for Blue Current.""" VERSION = 1 - _reauth_entry: config_entries.ConfigEntry | None = None + _reauth_entry: ConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} if user_input is not None: @@ -75,7 +74,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle a reauthorization flow request.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/bluemaestro/config_flow.py b/homeassistant/components/bluemaestro/config_flow.py index ccb548fa42b..b8bfec40f19 100644 --- a/homeassistant/components/bluemaestro/config_flow.py +++ b/homeassistant/components/bluemaestro/config_flow.py @@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import ( BluetoothServiceInfoBleak, async_discovered_service_info, ) -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -30,7 +29,7 @@ class BlueMaestroConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the bluetooth discovery step.""" await self.async_set_unique_id(discovery_info.address) self._abort_if_unique_id_configured() @@ -43,7 +42,7 @@ class BlueMaestroConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" assert self._discovered_device is not None device = self._discovered_device @@ -62,7 +61,7 @@ class BlueMaestroConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user step to pick discovered device.""" if user_input is not None: address = user_input[CONF_ADDRESS] diff --git a/homeassistant/components/bluetooth/config_flow.py b/homeassistant/components/bluetooth/config_flow.py index 76cf167790f..a71c32fc3ca 100644 --- a/homeassistant/components/bluetooth/config_flow.py +++ b/homeassistant/components/bluetooth/config_flow.py @@ -1,7 +1,7 @@ """Config flow to configure the Bluetooth integration.""" from __future__ import annotations -from typing import TYPE_CHECKING, Any, cast +from typing import Any, cast from bluetooth_adapters import ( ADAPTER_ADDRESS, @@ -13,7 +13,7 @@ from bluetooth_adapters import ( import voluptuous as vol from homeassistant.components import onboarding -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.core import callback from homeassistant.helpers.schema_config_entry_flow import ( SchemaFlowFormStep, @@ -24,9 +24,6 @@ from homeassistant.helpers.typing import DiscoveryInfoType from . import models from .const import CONF_ADAPTER, CONF_DETAILS, CONF_PASSIVE, DOMAIN -if TYPE_CHECKING: - from homeassistant.data_entry_flow import FlowResult - OPTIONS_SCHEMA = vol.Schema( { vol.Required(CONF_PASSIVE, default=False): bool, @@ -50,7 +47,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_integration_discovery( self, discovery_info: DiscoveryInfoType - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by discovery.""" self._adapter = cast(str, discovery_info[CONF_ADAPTER]) self._details = cast(AdapterDetails, discovery_info[CONF_DETAILS]) @@ -63,7 +60,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_single_adapter( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Select an adapter.""" adapter = self._adapter details = self._details @@ -86,7 +83,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_multiple_adapters( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if user_input is not None: assert self._adapters is not None @@ -138,7 +135,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" return await self.async_step_multiple_adapters() diff --git a/homeassistant/components/bmw_connected_drive/config_flow.py b/homeassistant/components/bmw_connected_drive/config_flow.py index 926706397a6..3fbee2a79bb 100644 --- a/homeassistant/components/bmw_connected_drive/config_flow.py +++ b/homeassistant/components/bmw_connected_drive/config_flow.py @@ -10,10 +10,15 @@ from bimmer_connected.models import MyBMWAPIError, MyBMWAuthError from httpx import RequestError import voluptuous as vol -from homeassistant import config_entries, core, exceptions +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlowWithConfigEntry, +) from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_SOURCE, CONF_USERNAME -from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError from . import DOMAIN from .const import CONF_ALLOWED_REGIONS, CONF_GCID, CONF_READ_ONLY, CONF_REFRESH_TOKEN @@ -27,9 +32,7 @@ DATA_SCHEMA = vol.Schema( ) -async def validate_input( - hass: core.HomeAssistant, data: dict[str, Any] -) -> dict[str, str]: +async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]: """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. @@ -56,16 +59,16 @@ async def validate_input( return retval -class BMWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BMWConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for MyBMW.""" VERSION = 1 - _reauth_entry: config_entries.ConfigEntry | None = None + _reauth_entry: ConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} @@ -112,7 +115,9 @@ class BMWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_show_form(step_id="user", data_schema=schema, errors=errors) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -122,24 +127,24 @@ class BMWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> BMWOptionsFlow: """Return a MyBMW option flow.""" return BMWOptionsFlow(config_entry) -class BMWOptionsFlow(config_entries.OptionsFlowWithConfigEntry): +class BMWOptionsFlow(OptionsFlowWithConfigEntry): """Handle a option flow for MyBMW.""" async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" return await self.async_step_account_options() async def async_step_account_options( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is not None: # Manually update & reload the config entry after options change. @@ -166,9 +171,9 @@ class BMWOptionsFlow(config_entries.OptionsFlowWithConfigEntry): ) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class InvalidAuth(exceptions.HomeAssistantError): +class InvalidAuth(HomeAssistantError): """Error to indicate there is invalid auth.""" diff --git a/homeassistant/components/bond/config_flow.py b/homeassistant/components/bond/config_flow.py index 33b5d2bf2c4..210dd3b3c4e 100644 --- a/homeassistant/components/bond/config_flow.py +++ b/homeassistant/components/bond/config_flow.py @@ -10,12 +10,11 @@ from aiohttp import ClientConnectionError, ClientResponseError from bond_async import Bond import voluptuous as vol -from homeassistant import config_entries, exceptions from homeassistant.components import zeroconf -from homeassistant.config_entries import ConfigEntryState +from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -66,7 +65,7 @@ async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> tuple[st return hub.bond_id, hub.name -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BondConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Bond.""" VERSION = 1 @@ -98,7 +97,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" name: str = discovery_info.name host: str = discovery_info.host @@ -132,7 +131,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle confirmation flow for discovered bond hub.""" errors = {} if user_input is not None: @@ -173,7 +172,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" errors = {} if user_input is not None: @@ -191,7 +190,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -class InputValidationError(exceptions.HomeAssistantError): +class InputValidationError(HomeAssistantError): """Error to indicate we cannot proceed due to invalid input.""" def __init__(self, base: str) -> None: diff --git a/homeassistant/components/bosch_shc/config_flow.py b/homeassistant/components/bosch_shc/config_flow.py index c19ab7726b2..28bf3a797b5 100644 --- a/homeassistant/components/bosch_shc/config_flow.py +++ b/homeassistant/components/bosch_shc/config_flow.py @@ -15,11 +15,10 @@ from boschshcpy.exceptions import ( ) import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_TOKEN from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from .const import ( CONF_HOSTNAME, @@ -87,20 +86,22 @@ def get_info_from_host( return {"title": information.name, "unique_id": information.unique_id} -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BoschSHCConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Bosch SHC.""" VERSION = 1 info: dict[str, str | None] host: str - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Dialog that informs the user that reauth is required.""" if user_input is None: return self.async_show_form( @@ -113,7 +114,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: @@ -136,7 +137,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_credentials( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the credentials step.""" errors: dict[str, str] = {} if user_input is not None: @@ -201,7 +202,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" if not discovery_info.name.startswith("Bosch SHC"): return self.async_abort(reason="not_bosch_shc") @@ -222,7 +223,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm_discovery( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle discovery confirm.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/braviatv/config_flow.py b/homeassistant/components/braviatv/config_flow.py index fd72203b249..6fc5c07130b 100644 --- a/homeassistant/components/braviatv/config_flow.py +++ b/homeassistant/components/braviatv/config_flow.py @@ -9,11 +9,9 @@ from aiohttp import CookieJar from pybravia import BraviaAuthError, BraviaClient, BraviaError, BraviaNotSupported import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_CLIENT_ID, CONF_HOST, CONF_MAC, CONF_NAME, CONF_PIN -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import instance_id from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.util.network import is_host_valid @@ -29,7 +27,7 @@ from .const import ( ) -class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BraviaTVConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Bravia TV integration.""" VERSION = 1 @@ -69,7 +67,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): await self.client.connect(pin=pin, clientid=client_id, nickname=nickname) await self.client.set_wol_mode(True) - async def async_create_device(self) -> FlowResult: + async def async_create_device(self) -> ConfigFlowResult: """Create Bravia TV device from config.""" assert self.client await self.async_connect_device() @@ -85,7 +83,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_create_entry(title=title, data=self.device_config) - async def async_reauth_device(self) -> FlowResult: + async def async_reauth_device(self) -> ConfigFlowResult: """Reauthorize Bravia TV device from config.""" assert self.entry assert self.client @@ -97,7 +95,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} @@ -117,7 +115,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_authorize( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle authorize step.""" self.create_client() @@ -138,7 +136,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_pin( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle PIN authorize step.""" errors: dict[str, str] = {} client_id, nickname = await self.gen_instance_ids() @@ -177,7 +175,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_psk( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle PSK authorize step.""" errors: dict[str, str] = {} @@ -204,7 +202,9 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a discovered device.""" parsed_url = urlparse(discovery_info.ssdp_location) host = parsed_url.hostname @@ -234,14 +234,16 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Allow the user to confirm adding the device.""" if user_input is not None: return await self.async_step_authorize() return self.async_show_form(step_id="confirm") - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) self.device_config = {**entry_data} diff --git a/homeassistant/components/bring/config_flow.py b/homeassistant/components/bring/config_flow.py index efd99fd938a..de4e278407b 100644 --- a/homeassistant/components/bring/config_flow.py +++ b/homeassistant/components/bring/config_flow.py @@ -10,7 +10,6 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_EMAIL, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.selector import ( TextSelector, @@ -45,7 +44,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> config_entries.ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/broadlink/config_flow.py b/homeassistant/components/broadlink/config_flow.py index 531119db6df..e3d6dda3488 100644 --- a/homeassistant/components/broadlink/config_flow.py +++ b/homeassistant/components/broadlink/config_flow.py @@ -14,10 +14,15 @@ from broadlink.exceptions import ( ) import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import dhcp +from homeassistant.config_entries import ( + SOURCE_IMPORT, + SOURCE_REAUTH, + ConfigFlow, + ConfigFlowResult, +) from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from homeassistant.helpers import config_validation as cv from .const import DEFAULT_PORT, DEFAULT_TIMEOUT, DEVICE_TYPES, DOMAIN @@ -26,7 +31,7 @@ from .helpers import format_mac _LOGGER = logging.getLogger(__name__) -class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class BroadlinkFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Broadlink config flow.""" VERSION = 1 @@ -58,7 +63,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): "host": device.host[0], } - async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Handle dhcp discovery.""" host = discovery_info.ip unique_id = discovery_info.macaddress.lower().replace(":", "") @@ -112,7 +119,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): else: device.timeout = timeout - if self.source != config_entries.SOURCE_REAUTH: + if self.source != SOURCE_REAUTH: await self.async_set_device(device) self._abort_if_unique_id_configured( updates={CONF_HOST: device.host[0], CONF_TIMEOUT: timeout} @@ -131,7 +138,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): _LOGGER.error("Failed to connect to the device at %s: %s", host, err_msg) - if self.source == config_entries.SOURCE_IMPORT: + if self.source == SOURCE_IMPORT: return self.async_abort(reason=errors["base"]) data_schema = { @@ -175,7 +182,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): else: await self.async_set_unique_id(device.mac.hex()) - if self.source == config_entries.SOURCE_IMPORT: + if self.source == SOURCE_IMPORT: _LOGGER.warning( ( "%s (%s at %s) is ready to be configured. Click " @@ -305,7 +312,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._async_abort_entries_match({CONF_HOST: import_info[CONF_HOST]}) return await self.async_step_user(import_info) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Reauthenticate to the device.""" device = blk.gendevice( entry_data[CONF_TYPE], diff --git a/homeassistant/components/brother/config_flow.py b/homeassistant/components/brother/config_flow.py index 55d47bb0c2c..13668224de3 100644 --- a/homeassistant/components/brother/config_flow.py +++ b/homeassistant/components/brother/config_flow.py @@ -6,10 +6,10 @@ from typing import Any from brother import Brother, SnmpError, UnsupportedModelError import voluptuous as vol -from homeassistant import config_entries, exceptions from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_TYPE -from homeassistant.data_entry_flow import FlowResult +from homeassistant.exceptions import HomeAssistantError from homeassistant.util.network import is_host_valid from .const import DOMAIN, PRINTER_TYPES @@ -23,7 +23,7 @@ DATA_SCHEMA = vol.Schema( ) -class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BrotherConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Brother Printer.""" VERSION = 1 @@ -35,7 +35,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} @@ -71,7 +71,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.host = discovery_info.host @@ -107,7 +107,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by zeroconf.""" if user_input is not None: title = f"{self.brother.model} {self.brother.serial}" @@ -127,5 +127,5 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -class InvalidHost(exceptions.HomeAssistantError): +class InvalidHost(HomeAssistantError): """Error to indicate that hostname/IP address is invalid.""" diff --git a/homeassistant/components/brottsplatskartan/config_flow.py b/homeassistant/components/brottsplatskartan/config_flow.py index 39c7421fa92..070708ee379 100644 --- a/homeassistant/components/brottsplatskartan/config_flow.py +++ b/homeassistant/components/brottsplatskartan/config_flow.py @@ -7,9 +7,8 @@ import uuid from brottsplatskartan import AREAS import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import selector from .const import CONF_APP_ID, CONF_AREA, DEFAULT_NAME, DOMAIN @@ -29,14 +28,14 @@ DATA_SCHEMA = vol.Schema( ) -class BPKConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class BPKConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Brottsplatskartan integration.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user step.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/brunt/config_flow.py b/homeassistant/components/brunt/config_flow.py index cfd3bfa69cb..8a9cf13a786 100644 --- a/homeassistant/components/brunt/config_flow.py +++ b/homeassistant/components/brunt/config_flow.py @@ -10,9 +10,8 @@ from aiohttp.client_exceptions import ServerDisconnectedError from brunt import BruntClientAsync import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -60,7 +59,7 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA) @@ -78,7 +77,9 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN): data=user_input, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -87,7 +88,7 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Dialog that informs the user that reauth is required.""" assert self._reauth_entry username = self._reauth_entry.data[CONF_USERNAME] diff --git a/homeassistant/components/bsblan/config_flow.py b/homeassistant/components/bsblan/config_flow.py index e12e6e5c6cf..8935bff26a3 100644 --- a/homeassistant/components/bsblan/config_flow.py +++ b/homeassistant/components/bsblan/config_flow.py @@ -6,10 +6,9 @@ from typing import Any from bsblan import BSBLAN, BSBLANError import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.device_registry import format_mac @@ -30,7 +29,7 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if user_input is None: return self._show_setup_form() @@ -49,7 +48,7 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN): return self._async_create_entry() @callback - def _show_setup_form(self, errors: dict | None = None) -> FlowResult: + def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult: """Show the setup form to the user.""" return self.async_show_form( step_id="user", @@ -66,7 +65,7 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN): ) @callback - def _async_create_entry(self) -> FlowResult: + def _async_create_entry(self) -> ConfigFlowResult: return self.async_create_entry( title=format_mac(self.mac), data={ diff --git a/homeassistant/components/bthome/config_flow.py b/homeassistant/components/bthome/config_flow.py index 41440cb435f..48b24f1229a 100644 --- a/homeassistant/components/bthome/config_flow.py +++ b/homeassistant/components/bthome/config_flow.py @@ -14,9 +14,8 @@ from homeassistant.components.bluetooth import ( BluetoothServiceInfo, async_discovered_service_info, ) -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -47,7 +46,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the bluetooth discovery step.""" await self.async_set_unique_id(discovery_info.address) self._abort_if_unique_id_configured() @@ -67,7 +66,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_get_encryption_key( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Enter a bindkey for an encrypted BTHome device.""" assert self._discovery_info assert self._discovered_device @@ -101,7 +100,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" if user_input is not None or not onboarding.async_is_onboarded(self.hass): return self._async_get_or_create_entry() @@ -114,7 +113,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user step to pick discovered device.""" if user_input is not None: address = user_input[CONF_ADDRESS] @@ -157,7 +156,9 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): data_schema=vol.Schema({vol.Required(CONF_ADDRESS): vol.In(titles)}), ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle a flow initialized by a reauth event.""" entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) assert entry is not None @@ -173,7 +174,9 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN): # Otherwise there wasn't actually encryption so abort return self.async_abort(reason="reauth_successful") - def _async_get_or_create_entry(self, bindkey: str | None = None) -> FlowResult: + def _async_get_or_create_entry( + self, bindkey: str | None = None + ) -> ConfigFlowResult: data: dict[str, Any] = {} if bindkey: data["bindkey"] = bindkey diff --git a/homeassistant/components/buienradar/config_flow.py b/homeassistant/components/buienradar/config_flow.py index 1e77693f7fb..db9e6b02614 100644 --- a/homeassistant/components/buienradar/config_flow.py +++ b/homeassistant/components/buienradar/config_flow.py @@ -6,11 +6,9 @@ from typing import Any, cast import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import selector import homeassistant.helpers.config_validation as cv from homeassistant.helpers.schema_config_entry_flow import ( @@ -73,7 +71,7 @@ OPTIONS_FLOW = { } -class BuienradarFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class BuienradarFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for buienradar.""" VERSION = 1 @@ -88,7 +86,7 @@ class BuienradarFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if user_input is not None: lat = user_input.get(CONF_LATITUDE) diff --git a/homeassistant/components/caldav/config_flow.py b/homeassistant/components/caldav/config_flow.py index f2fa51c7f60..3710f7f1b4b 100644 --- a/homeassistant/components/caldav/config_flow.py +++ b/homeassistant/components/caldav/config_flow.py @@ -9,9 +9,8 @@ from caldav.lib.error import AuthorizationError, DAVError import requests import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME, CONF_VERIFY_SSL -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from .const import DOMAIN @@ -29,15 +28,15 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class CalDavConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for caldav.""" VERSION = 1 - _reauth_entry: config_entries.ConfigEntry | None = None + _reauth_entry: ConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: @@ -88,7 +87,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return "unknown" return None - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -97,7 +98,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm reauth dialog.""" errors = {} assert self._reauth_entry diff --git a/homeassistant/components/canary/config_flow.py b/homeassistant/components/canary/config_flow.py index 6b3176f6bbd..22bc26ee0f4 100644 --- a/homeassistant/components/canary/config_flow.py +++ b/homeassistant/components/canary/config_flow.py @@ -8,10 +8,14 @@ from canary.api import Api from requests.exceptions import ConnectTimeout, HTTPError import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + 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 .const import ( CONF_FFMPEG_ARGUMENTS, @@ -51,13 +55,13 @@ class CanaryConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_import( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by configuration file.""" return await self.async_step_user(user_input) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -107,7 +111,7 @@ class CanaryOptionsFlowHandler(OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage Canary options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/cast/config_flow.py b/homeassistant/components/cast/config_flow.py index e58bcb71b28..6a6bb667b82 100644 --- a/homeassistant/components/cast/config_flow.py +++ b/homeassistant/components/cast/config_flow.py @@ -5,11 +5,15 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import onboarding, zeroconf +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_UUID from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from .const import CONF_IGNORE_CEC, CONF_KNOWN_HOSTS, DOMAIN @@ -19,7 +23,7 @@ KNOWN_HOSTS_SCHEMA = vol.Schema(vol.All(cv.ensure_list, [cv.string])) WANTED_UUID_SCHEMA = vol.Schema(vol.All(cv.ensure_list, [cv.string])) -class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class FlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 @@ -33,7 +37,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> CastOptionsFlowHandler: """Get the options flow for this handler.""" return CastOptionsFlowHandler(config_entry) @@ -47,7 +51,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" if self._async_in_progress() or self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -101,10 +105,10 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): } -class CastOptionsFlowHandler(config_entries.OptionsFlow): +class CastOptionsFlowHandler(OptionsFlow): """Handle Google Cast options.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize Google Cast options flow.""" self.config_entry = config_entry self.updated_config: dict[str, Any] = {} diff --git a/homeassistant/components/ccm15/config_flow.py b/homeassistant/components/ccm15/config_flow.py index efde47b8d30..e4ebb758cd8 100644 --- a/homeassistant/components/ccm15/config_flow.py +++ b/homeassistant/components/ccm15/config_flow.py @@ -7,9 +7,8 @@ from typing import Any from ccm15 import CCM15Device import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import DEFAULT_TIMEOUT, DOMAIN @@ -24,14 +23,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class CCM15ConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Midea ccm15 AC Controller.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/cert_expiry/config_flow.py b/homeassistant/components/cert_expiry/config_flow.py index b3ceb95d301..2201bf2714f 100644 --- a/homeassistant/components/cert_expiry/config_flow.py +++ b/homeassistant/components/cert_expiry/config_flow.py @@ -7,9 +7,8 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import SOURCE_IMPORT, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from .const import DEFAULT_PORT, DOMAIN from .errors import ( @@ -23,7 +22,7 @@ from .helper import get_cert_expiry_timestamp _LOGGER = logging.getLogger(__name__) -class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class CertexpiryConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 @@ -57,7 +56,7 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: Mapping[str, Any] | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when user initializes a integration.""" self._errors = {} if user_input is not None: @@ -73,7 +72,7 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): title=title, data={CONF_HOST: host, CONF_PORT: port}, ) - if self.context["source"] == config_entries.SOURCE_IMPORT: + if self.context["source"] == SOURCE_IMPORT: _LOGGER.error("Config import failed for %s", user_input[CONF_HOST]) return self.async_abort(reason="import_failed") else: @@ -97,7 +96,7 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import( self, user_input: Mapping[str, Any] | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Import a config entry. Only host was required in the yaml file all other fields are optional diff --git a/homeassistant/components/cloud/config_flow.py b/homeassistant/components/cloud/config_flow.py index a9554d97294..0cf4b941680 100644 --- a/homeassistant/components/cloud/config_flow.py +++ b/homeassistant/components/cloud/config_flow.py @@ -3,8 +3,7 @@ from __future__ import annotations from typing import Any -from homeassistant.config_entries import ConfigFlow -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from .const import DOMAIN @@ -16,7 +15,7 @@ class CloudConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_system( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the system step.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/cloudflare/config_flow.py b/homeassistant/components/cloudflare/config_flow.py index 99f6109be4a..e92ba43c503 100644 --- a/homeassistant/components/cloudflare/config_flow.py +++ b/homeassistant/components/cloudflare/config_flow.py @@ -9,10 +9,9 @@ import pycfdns import voluptuous as vol from homeassistant.components import persistent_notification -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_TOKEN, CONF_ZONE from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -85,14 +84,16 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN): self.zones: list[pycfdns.ZoneModel] | None = None self.records: list[pycfdns.RecordModel] | None = None - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle initiation of re-authentication with Cloudflare.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle re-authentication with Cloudflare.""" errors: dict[str, str] = {} @@ -122,7 +123,7 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -145,7 +146,7 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_zone( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the picking the zone.""" errors: dict[str, str] = {} @@ -167,7 +168,7 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_records( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the picking the zone records.""" if user_input is not None: diff --git a/homeassistant/components/co2signal/config_flow.py b/homeassistant/components/co2signal/config_flow.py index a952f016671..37f5edaa227 100644 --- a/homeassistant/components/co2signal/config_flow.py +++ b/homeassistant/components/co2signal/config_flow.py @@ -12,15 +12,13 @@ from aioelectricitymaps import ( ) import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_API_KEY, CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE, ) -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.selector import ( @@ -38,7 +36,7 @@ TYPE_SPECIFY_COORDINATES = "specify_coordinates" TYPE_SPECIFY_COUNTRY = "specify_country_code" -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Co2signal.""" VERSION = 1 @@ -47,7 +45,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" data_schema = vol.Schema( { @@ -86,7 +84,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_coordinates( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Validate coordinates.""" data_schema = vol.Schema( { @@ -109,7 +107,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_country( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Validate country.""" data_schema = vol.Schema( { @@ -125,7 +123,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): "country", data_schema, {**self._data, **user_input} ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle the reauth step.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -140,7 +140,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def _validate_and_create( self, step_id: str, data_schema: vol.Schema, data: Mapping[str, Any] - ) -> FlowResult: + ) -> ConfigFlowResult: """Validate data and show form if it is invalid.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/coinbase/config_flow.py b/homeassistant/components/coinbase/config_flow.py index 38053295411..3ffb93b5ab9 100644 --- a/homeassistant/components/coinbase/config_flow.py +++ b/homeassistant/components/coinbase/config_flow.py @@ -8,10 +8,15 @@ from coinbase.wallet.client import Client from coinbase.wallet.error import AuthenticationError import voluptuous as vol -from homeassistant import config_entries, core, exceptions +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN -from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from . import get_accounts @@ -48,7 +53,7 @@ def get_user_from_client(api_key, api_token): return user -async def validate_api(hass: core.HomeAssistant, data): +async def validate_api(hass: HomeAssistant, data): """Validate the credentials.""" try: @@ -72,9 +77,7 @@ async def validate_api(hass: core.HomeAssistant, data): return {"title": user["name"]} -async def validate_options( - hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, options -): +async def validate_options(hass: HomeAssistant, config_entry: ConfigEntry, options): """Validate the requested resources are provided by API.""" client = hass.data[DOMAIN][config_entry.entry_id].client @@ -100,14 +103,14 @@ async def validate_options( return True -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class CoinbaseConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Coinbase.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is None: @@ -139,22 +142,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Handle a option flow for Coinbase.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" errors = {} @@ -216,29 +219,29 @@ class OptionsFlowHandler(config_entries.OptionsFlow): ) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class InvalidAuth(exceptions.HomeAssistantError): +class InvalidAuth(HomeAssistantError): """Error to indicate there is invalid auth.""" -class InvalidSecret(exceptions.HomeAssistantError): +class InvalidSecret(HomeAssistantError): """Error to indicate auth failed due to invalid secret.""" -class InvalidKey(exceptions.HomeAssistantError): +class InvalidKey(HomeAssistantError): """Error to indicate auth failed due to invalid key.""" -class AlreadyConfigured(exceptions.HomeAssistantError): +class AlreadyConfigured(HomeAssistantError): """Error to indicate Coinbase API Key is already configured.""" -class CurrencyUnavailable(exceptions.HomeAssistantError): +class CurrencyUnavailable(HomeAssistantError): """Error to indicate the requested currency resource is not provided by the API.""" -class ExchangeRateUnavailable(exceptions.HomeAssistantError): +class ExchangeRateUnavailable(HomeAssistantError): """Error to indicate the requested exchange rate resource is not provided by the API.""" diff --git a/homeassistant/components/color_extractor/config_flow.py b/homeassistant/components/color_extractor/config_flow.py index 32b803d14f9..dea971913b2 100644 --- a/homeassistant/components/color_extractor/config_flow.py +++ b/homeassistant/components/color_extractor/config_flow.py @@ -3,9 +3,9 @@ from __future__ import annotations from typing import Any -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN -from homeassistant.data_entry_flow import FlowResult, FlowResultType +from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from .const import DEFAULT_NAME, DOMAIN @@ -18,7 +18,7 @@ class ColorExtractorConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -28,7 +28,7 @@ class ColorExtractorConfigFlow(ConfigFlow, domain=DOMAIN): return self.async_show_form(step_id="user") - async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult: + async def async_step_import(self, user_input: dict[str, Any]) -> ConfigFlowResult: """Handle import from configuration.yaml.""" result = await self.async_step_user(user_input) if result["type"] == FlowResultType.CREATE_ENTRY: diff --git a/homeassistant/components/comelit/config_flow.py b/homeassistant/components/comelit/config_flow.py index bbb671a29a7..54d5cfc0d32 100644 --- a/homeassistant/components/comelit/config_flow.py +++ b/homeassistant/components/comelit/config_flow.py @@ -13,10 +13,10 @@ from aiocomelit.api import ComelitCommonApi from aiocomelit.const import BRIDGE import voluptuous as vol -from homeassistant import core, exceptions -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT, CONF_TYPE -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from .const import _LOGGER, DEFAULT_PORT, DEVICE_TYPE_LIST, DOMAIN @@ -41,9 +41,7 @@ def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema: STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PIN): cv.positive_int}) -async def validate_input( - hass: core.HomeAssistant, data: dict[str, Any] -) -> dict[str, str]: +async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]: """Validate the user input allows us to connect.""" api: ComelitCommonApi @@ -76,7 +74,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form( @@ -103,7 +101,9 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=user_form_schema(user_input), errors=errors ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauth flow.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -117,7 +117,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle reauth confirm.""" assert self._reauth_entry errors = {} @@ -163,9 +163,9 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN): ) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class InvalidAuth(exceptions.HomeAssistantError): +class InvalidAuth(HomeAssistantError): """Error to indicate there is invalid auth.""" diff --git a/homeassistant/components/control4/config_flow.py b/homeassistant/components/control4/config_flow.py index b93e586b7ca..d0af1d03ed7 100644 --- a/homeassistant/components/control4/config_flow.py +++ b/homeassistant/components/control4/config_flow.py @@ -9,7 +9,7 @@ from pyControl4.director import C4Director from pyControl4.error_handling import NotFound, Unauthorized import voluptuous as vol -from homeassistant import config_entries, exceptions +from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -17,6 +17,7 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import callback +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers.device_registry import format_mac @@ -86,7 +87,7 @@ class Control4Validator: return False -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class Control4ConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Control4.""" VERSION = 1 @@ -137,16 +138,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Handle a option flow for Control4.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.config_entry = config_entry @@ -168,9 +169,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_form(step_id="init", data_schema=data_schema) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class InvalidAuth(exceptions.HomeAssistantError): +class InvalidAuth(HomeAssistantError): """Error to indicate there is invalid auth.""" diff --git a/homeassistant/components/coolmaster/config_flow.py b/homeassistant/components/coolmaster/config_flow.py index ad3817b77ce..41a96df1e7a 100644 --- a/homeassistant/components/coolmaster/config_flow.py +++ b/homeassistant/components/coolmaster/config_flow.py @@ -7,10 +7,9 @@ from pycoolmasternet_async import CoolMasterNet import voluptuous as vol from homeassistant.components.climate import HVACMode -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import CONF_SUPPORTED_MODES, CONF_SWING_SUPPORT, DEFAULT_PORT, DOMAIN @@ -46,7 +45,7 @@ class CoolmasterConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 @callback - def _async_get_entry(self, data: dict[str, Any]) -> FlowResult: + def _async_get_entry(self, data: dict[str, Any]) -> ConfigFlowResult: supported_modes = [ key for (key, value) in data.items() if key in AVAILABLE_MODES and value ] @@ -62,7 +61,7 @@ class CoolmasterConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" if user_input is None: return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA) diff --git a/homeassistant/components/cpuspeed/config_flow.py b/homeassistant/components/cpuspeed/config_flow.py index 3c7d529364c..a6d760d49f3 100644 --- a/homeassistant/components/cpuspeed/config_flow.py +++ b/homeassistant/components/cpuspeed/config_flow.py @@ -5,8 +5,7 @@ from typing import Any from cpuinfo import cpuinfo -from homeassistant.config_entries import ConfigFlow -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from .const import DOMAIN @@ -20,7 +19,7 @@ class CPUSpeedFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" await self.async_set_unique_id(DOMAIN) self._abort_if_unique_id_configured() diff --git a/homeassistant/components/crownstone/config_flow.py b/homeassistant/components/crownstone/config_flow.py index 7c0ea4fd27d..424d0a93314 100644 --- a/homeassistant/components/crownstone/config_flow.py +++ b/homeassistant/components/crownstone/config_flow.py @@ -14,10 +14,15 @@ from serial.tools.list_ports_common import ListPortInfo import voluptuous as vol from homeassistant.components import usb -from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow +from homeassistant.config_entries import ( + ConfigEntry, + ConfigEntryBaseFlow, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowHandler, FlowResult from homeassistant.helpers import aiohttp_client from .const import ( @@ -37,13 +42,13 @@ CONFIG_FLOW = "config_flow" OPTIONS_FLOW = "options_flow" -class BaseCrownstoneFlowHandler(FlowHandler): +class BaseCrownstoneFlowHandler(ConfigEntryBaseFlow): """Represent the base flow for Crownstone.""" cloud: CrownstoneCloud def __init__( - self, flow_type: str, create_entry_cb: Callable[..., FlowResult] + self, flow_type: str, create_entry_cb: Callable[..., ConfigFlowResult] ) -> None: """Set up flow instance.""" self.flow_type = flow_type @@ -53,7 +58,7 @@ class BaseCrownstoneFlowHandler(FlowHandler): async def async_step_usb_config( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Set up a Crownstone USB dongle.""" list_of_ports = await self.hass.async_add_executor_job( serial.tools.list_ports.comports @@ -91,7 +96,7 @@ class BaseCrownstoneFlowHandler(FlowHandler): async def async_step_usb_manual_config( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manually enter Crownstone USB dongle path.""" if user_input is None: return self.async_show_form( @@ -104,7 +109,7 @@ class BaseCrownstoneFlowHandler(FlowHandler): async def async_step_usb_sphere_config( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Select a Crownstone sphere that the USB operates in.""" spheres = {sphere.name: sphere.cloud_id for sphere in self.cloud.cloud_data} # no need to select if there's only 1 option @@ -146,7 +151,7 @@ class CrownstoneConfigFlowHandler(BaseCrownstoneFlowHandler, ConfigFlow, domain= async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is None: @@ -189,7 +194,7 @@ class CrownstoneConfigFlowHandler(BaseCrownstoneFlowHandler, ConfigFlow, domain= self.login_info = user_input return await self.async_step_usb_config() - def async_create_new_entry(self) -> FlowResult: + def async_create_new_entry(self) -> ConfigFlowResult: """Create a new entry.""" return super().async_create_entry( title=f"Account: {self.login_info[CONF_EMAIL]}", @@ -212,7 +217,7 @@ class CrownstoneOptionsFlowHandler(BaseCrownstoneFlowHandler, OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage Crownstone options.""" self.cloud: CrownstoneCloud = self.hass.data[DOMAIN][self.entry.entry_id].cloud @@ -250,7 +255,7 @@ class CrownstoneOptionsFlowHandler(BaseCrownstoneFlowHandler, OptionsFlow): return self.async_show_form(step_id="init", data_schema=options_schema) - def async_create_new_entry(self) -> FlowResult: + def async_create_new_entry(self) -> ConfigFlowResult: """Create a new entry.""" # these attributes will only change when a usb was configured if self.usb_path is not None and self.usb_sphere_id is not None: diff --git a/homeassistant/components/daikin/config_flow.py b/homeassistant/components/daikin/config_flow.py index abd2d78c7fb..25e504f915a 100644 --- a/homeassistant/components/daikin/config_flow.py +++ b/homeassistant/components/daikin/config_flow.py @@ -11,10 +11,9 @@ from pydaikin.daikin_base import Appliance, DaikinException from pydaikin.discovery import Discovery import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_UUID -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN, KEY_MAC, TIMEOUT @@ -22,7 +21,7 @@ from .const import DOMAIN, KEY_MAC, TIMEOUT _LOGGER = logging.getLogger(__name__) -class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class FlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 @@ -49,7 +48,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): key: str | None = None, uuid: str | None = None, password: str | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Register new entry.""" if not self.unique_id: await self.async_set_unique_id(mac) @@ -68,7 +67,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def _create_device( self, host: str, key: str | None = None, password: str | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Create device.""" # BRP07Cxx devices needs uuid together with key if key: @@ -122,7 +121,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """User initiated config flow.""" if user_input is None: return self.async_show_form(step_id="user", data_schema=self.schema) @@ -141,7 +140,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Prepare configuration for a discovered Daikin device.""" _LOGGER.debug("Zeroconf user_input: %s", discovery_info) devices = Discovery().poll(ip=discovery_info.host) diff --git a/homeassistant/components/deconz/config_flow.py b/homeassistant/components/deconz/config_flow.py index 99fa6412364..3eb6b808805 100644 --- a/homeassistant/components/deconz/config_flow.py +++ b/homeassistant/components/deconz/config_flow.py @@ -19,13 +19,17 @@ from pydeconz.utils import ( ) import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp from homeassistant.components.hassio import HassioServiceInfo -from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow +from homeassistant.config_entries import ( + SOURCE_HASSIO, + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from .const import ( @@ -80,7 +84,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a deCONZ config flow start. Let user choose between discovered bridges and manual configuration. @@ -126,7 +130,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_manual_input( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manual configuration.""" if user_input: self.host = user_input[CONF_HOST] @@ -145,7 +149,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_link( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Attempt to link with the deCONZ bridge.""" errors: dict[str, str] = {} @@ -173,7 +177,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): return self.async_show_form(step_id="link", errors=errors) - async def _create_entry(self) -> FlowResult: + async def _create_entry(self) -> ConfigFlowResult: """Create entry for gateway.""" if not self.bridge_id: session = aiohttp_client.async_get_clientsession(self.hass) @@ -205,7 +209,9 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): }, ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Trigger a reauthentication flow.""" self.context["title_placeholders"] = {CONF_HOST: entry_data[CONF_HOST]} @@ -214,7 +220,9 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): return await self.async_step_link() - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a discovered deCONZ bridge.""" if LOGGER.isEnabledFor(logging.DEBUG): LOGGER.debug("deCONZ SSDP discovery %s", pformat(discovery_info)) @@ -223,7 +231,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): parsed_url = urlparse(discovery_info.ssdp_location) entry = await self.async_set_unique_id(self.bridge_id) - if entry and entry.source == config_entries.SOURCE_HASSIO: + if entry and entry.source == SOURCE_HASSIO: return self.async_abort(reason="already_configured") self.host = cast(str, parsed_url.hostname) @@ -245,7 +253,9 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): return await self.async_step_link() - async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult: + async def async_step_hassio( + self, discovery_info: HassioServiceInfo + ) -> ConfigFlowResult: """Prepare configuration for a Hass.io deCONZ bridge. This flow is triggered by the discovery component. @@ -275,7 +285,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_hassio_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm a Hass.io discovery.""" if user_input is not None: @@ -299,13 +309,13 @@ class DeconzOptionsFlowHandler(OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the deCONZ options.""" return await self.async_step_deconz_devices() async def async_step_deconz_devices( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the deconz devices options.""" if user_input is not None: self.options.update(user_input) diff --git a/homeassistant/components/deluge/config_flow.py b/homeassistant/components/deluge/config_flow.py index db2598e1f67..ae28f32767d 100644 --- a/homeassistant/components/deluge/config_flow.py +++ b/homeassistant/components/deluge/config_flow.py @@ -8,7 +8,7 @@ from typing import Any from deluge_client.client import DelugeRPCClient import voluptuous as vol -from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow +from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -16,7 +16,6 @@ from homeassistant.const import ( CONF_SOURCE, CONF_USERNAME, ) -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import ( @@ -33,7 +32,7 @@ class DelugeFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" errors = {} @@ -75,7 +74,9 @@ class DelugeFlowHandler(ConfigFlow, domain=DOMAIN): ) return self.async_show_form(step_id="user", data_schema=schema, errors=errors) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle a reauthorization flow request.""" return await self.async_step_user() diff --git a/homeassistant/components/demo/config_flow.py b/homeassistant/components/demo/config_flow.py index 75439e48c08..5178b04b527 100644 --- a/homeassistant/components/demo/config_flow.py +++ b/homeassistant/components/demo/config_flow.py @@ -5,9 +5,13 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from . import DOMAIN @@ -19,7 +23,7 @@ CONF_SELECT = "select" CONF_MULTISELECT = "multi" -class DemoConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DemoConfigFlow(ConfigFlow, domain=DOMAIN): """Demo configuration flow.""" VERSION = 1 @@ -27,33 +31,33 @@ class DemoConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) - async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult: + async def async_step_import(self, import_info: dict[str, Any]) -> ConfigFlowResult: """Set the config entry up from yaml.""" return self.async_create_entry(title="Demo", data=import_info) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Handle options.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.config_entry = config_entry self.options = dict(config_entry.options) async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" return await self.async_step_options_1() async def async_step_options_1( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: self.options.update(user_input) @@ -78,7 +82,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow): async def async_step_options_2( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options 2.""" if user_input is not None: self.options.update(user_input) @@ -109,6 +113,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow): ), ) - async def _update_options(self) -> FlowResult: + async def _update_options(self) -> ConfigFlowResult: """Update config entry options.""" return self.async_create_entry(title="", data=self.options) diff --git a/homeassistant/components/denonavr/config_flow.py b/homeassistant/components/denonavr/config_flow.py index e93fba09a9d..9225844285e 100644 --- a/homeassistant/components/denonavr/config_flow.py +++ b/homeassistant/components/denonavr/config_flow.py @@ -9,11 +9,15 @@ import denonavr from denonavr.exceptions import AvrNetworkError, AvrTimoutError import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_TYPE from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.httpx_client import get_async_client from .receiver import ConnectDenonAVR @@ -44,16 +48,16 @@ DEFAULT_USE_TELNET_NEW_INSTALL = True CONFIG_SCHEMA = vol.Schema({vol.Optional(CONF_HOST): str}) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Options for the component.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Init object.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) @@ -92,7 +96,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_form(step_id="init", data_schema=settings_schema) -class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DenonAvrFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Denon AVR config flow.""" VERSION = 1 @@ -111,14 +115,14 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Get the options flow.""" return OptionsFlowHandler(config_entry) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" errors = {} if user_input is not None: @@ -145,7 +149,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_select( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle multiple receivers found.""" errors: dict[str, str] = {} if user_input is not None: @@ -166,7 +170,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Allow the user to confirm adding the device.""" if user_input is not None: return await self.async_step_connect() @@ -176,7 +180,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_connect( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Connect to the receiver.""" assert self.host connect_denonavr = ConnectDenonAVR( @@ -230,7 +234,9 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): options={CONF_USE_TELNET: DEFAULT_USE_TELNET_NEW_INSTALL}, ) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a discovered Denon AVR. This flow is triggered by the SSDP component. It will check if the diff --git a/homeassistant/components/devialet/config_flow.py b/homeassistant/components/devialet/config_flow.py index de52788de50..e244bfeb895 100644 --- a/homeassistant/components/devialet/config_flow.py +++ b/homeassistant/components/devialet/config_flow.py @@ -8,9 +8,8 @@ from devialet.devialet_api import DevialetApi import voluptuous as vol from homeassistant.components import zeroconf -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -31,7 +30,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN): self._serial: str | None = None self._errors: dict[str, str] = {} - async def async_validate_input(self) -> FlowResult | None: + async def async_validate_input(self) -> ConfigFlowResult | None: """Validate the input using the Devialet API.""" self._errors.clear() @@ -53,7 +52,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user or zeroconf.""" if user_input is not None: @@ -70,7 +69,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" LOGGER.info("Devialet device found via ZEROCONF: %s", discovery_info) @@ -87,7 +86,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user-confirmation of discovered node.""" title = f"{self._name} ({self._model})" diff --git a/homeassistant/components/devolo_home_control/config_flow.py b/homeassistant/components/devolo_home_control/config_flow.py index aef9592d2e9..9ae31432b53 100644 --- a/homeassistant/components/devolo_home_control/config_flow.py +++ b/homeassistant/components/devolo_home_control/config_flow.py @@ -6,19 +6,17 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from . import configure_mydevolo from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES from .exceptions import CredentialsInvalid, UuidChanged -class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DevoloHomeControlFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a devolo HomeControl config flow.""" VERSION = 1 @@ -34,7 +32,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if self.show_advanced_options: self.data_schema[vol.Required(CONF_MYDEVOLO, default=self._url)] = str @@ -47,7 +45,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" # Check if it is a gateway if discovery_info.properties.get("MT") in SUPPORTED_MODEL_TYPES: @@ -57,7 +55,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by zeroconf.""" if user_input is None: return self._show_form(step_id="zeroconf_confirm") @@ -68,7 +66,9 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): step_id="zeroconf_confirm", errors={"base": "invalid_auth"} ) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauthentication.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -82,7 +82,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by reauthentication.""" if user_input is None: return self._show_form(step_id="reauth_confirm") @@ -97,7 +97,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): step_id="reauth_confirm", errors={"base": "reauth_failed"} ) - async def _connect_mydevolo(self, user_input: dict[str, Any]) -> FlowResult: + async def _connect_mydevolo(self, user_input: dict[str, Any]) -> ConfigFlowResult: """Connect to mydevolo.""" user_input[CONF_MYDEVOLO] = user_input.get(CONF_MYDEVOLO, self._url) mydevolo = configure_mydevolo(conf=user_input) @@ -135,7 +135,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @callback def _show_form( self, step_id: str, errors: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the form to the user.""" return self.async_show_form( step_id=step_id, diff --git a/homeassistant/components/devolo_home_network/config_flow.py b/homeassistant/components/devolo_home_network/config_flow.py index 08892e19e4e..3f0ec0a02b7 100644 --- a/homeassistant/components/devolo_home_network/config_flow.py +++ b/homeassistant/components/devolo_home_network/config_flow.py @@ -9,10 +9,10 @@ from devolo_plc_api.device import Device from devolo_plc_api.exceptions.device import DeviceNotFound import voluptuous as vol -from homeassistant import config_entries, core from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS, CONF_NAME, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant from homeassistant.helpers.httpx_client import get_async_client from .const import DOMAIN, PRODUCT, SERIAL_NUMBER, TITLE @@ -23,9 +23,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required(CONF_IP_ADDRESS): str}) STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Optional(CONF_PASSWORD): str}) -async def validate_input( - hass: core.HomeAssistant, data: dict[str, Any] -) -> dict[str, str]: +async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]: """Validate the user input allows us to connect. Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user. @@ -44,14 +42,14 @@ async def validate_input( } -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DevoloHomeNetworkConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for devolo Home Network.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict = {} @@ -79,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" if discovery_info.properties["MT"] in ["2600", "2601"]: return self.async_abort(reason="home_control") @@ -99,7 +97,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by zeroconf.""" title = self.context["title_placeholders"][CONF_NAME] if user_input is not None: @@ -113,7 +111,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): description_placeholders={"host_name": title}, ) - async def async_step_reauth(self, data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth(self, data: Mapping[str, Any]) -> ConfigFlowResult: """Handle reauthentication.""" self.context[CONF_HOST] = data[CONF_IP_ADDRESS] self.context["title_placeholders"][PRODUCT] = self.hass.data[DOMAIN][ @@ -123,7 +121,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by reauthentication.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/dexcom/config_flow.py b/homeassistant/components/dexcom/config_flow.py index 6ccb09881af..b099a97e0b2 100644 --- a/homeassistant/components/dexcom/config_flow.py +++ b/homeassistant/components/dexcom/config_flow.py @@ -4,7 +4,7 @@ from __future__ import annotations from pydexcom import AccountError, Dexcom, SessionError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.const import CONF_PASSWORD, CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME from homeassistant.core import callback @@ -19,7 +19,7 @@ DATA_SCHEMA = vol.Schema( ) -class DexcomConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DexcomConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Dexcom.""" VERSION = 1 @@ -56,16 +56,16 @@ class DexcomConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> DexcomOptionsFlowHandler: """Get the options flow for this handler.""" return DexcomOptionsFlowHandler(config_entry) -class DexcomOptionsFlowHandler(config_entries.OptionsFlow): +class DexcomOptionsFlowHandler(OptionsFlow): """Handle a option flow for Dexcom.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.config_entry = config_entry diff --git a/homeassistant/components/directv/config_flow.py b/homeassistant/components/directv/config_flow.py index b3209638012..6c5654b185e 100644 --- a/homeassistant/components/directv/config_flow.py +++ b/homeassistant/components/directv/config_flow.py @@ -9,10 +9,9 @@ from directv import DIRECTV, DIRECTVError import voluptuous as vol from homeassistant.components import ssdp -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import CONF_RECEIVER_ID, DOMAIN @@ -46,7 +45,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if user_input is None: return self._show_setup_form() @@ -66,7 +65,9 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN): return self.async_create_entry(title=user_input[CONF_HOST], data=user_input) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle SSDP discovery.""" host = urlparse(discovery_info.ssdp_location).hostname receiver_id = None @@ -101,7 +102,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_ssdp_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a confirmation flow initiated by SSDP.""" if user_input is None: return self.async_show_form( @@ -115,7 +116,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN): data=self.discovery_info, ) - def _show_setup_form(self, errors: dict | None = None) -> FlowResult: + def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult: """Show the setup form to the user.""" return self.async_show_form( step_id="user", diff --git a/homeassistant/components/discord/config_flow.py b/homeassistant/components/discord/config_flow.py index 14c2cc6c040..e93f2cc565f 100644 --- a/homeassistant/components/discord/config_flow.py +++ b/homeassistant/components/discord/config_flow.py @@ -9,9 +9,8 @@ from aiohttp.client_exceptions import ClientConnectorError import nextcord import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_TOKEN, CONF_NAME -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN, URL_PLACEHOLDER @@ -20,16 +19,18 @@ _LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema({vol.Required(CONF_API_TOKEN): str}) -class DiscordFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DiscordFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for Discord.""" - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle a reauthorization flow request.""" return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm reauth dialog.""" errors = {} @@ -52,7 +53,7 @@ class DiscordFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" errors = {} diff --git a/homeassistant/components/discovergy/config_flow.py b/homeassistant/components/discovergy/config_flow.py index d0e0c272d24..ab57bb138de 100644 --- a/homeassistant/components/discovergy/config_flow.py +++ b/homeassistant/components/discovergy/config_flow.py @@ -10,10 +10,8 @@ from pydiscovergy.authentication import BasicAuth import pydiscovergy.error as discovergyError import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_EMAIL, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.httpx_client import get_async_client from homeassistant.helpers.selector import ( TextSelector, @@ -48,7 +46,7 @@ CONFIG_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DiscovergyConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Discovergy.""" VERSION = 1 @@ -57,7 +55,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form( @@ -67,14 +65,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self._validate_and_save(user_input) - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle the initial step.""" self._existing_entry = await self.async_set_unique_id(self.context["unique_id"]) return await self._validate_and_save(entry_data, step_id="reauth") async def _validate_and_save( self, user_input: Mapping[str, Any] | None = None, step_id: str = "user" - ) -> FlowResult: + ) -> ConfigFlowResult: """Validate user input and create config entry.""" errors = {} diff --git a/homeassistant/components/dlink/config_flow.py b/homeassistant/components/dlink/config_flow.py index 09df5571a78..a600c0e148f 100644 --- a/homeassistant/components/dlink/config_flow.py +++ b/homeassistant/components/dlink/config_flow.py @@ -7,24 +7,25 @@ from typing import Any from pyW215.pyW215 import SmartPlug import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import dhcp +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from .const import CONF_USE_LEGACY_PROTOCOL, DEFAULT_NAME, DEFAULT_USERNAME, DOMAIN _LOGGER = logging.getLogger(__name__) -class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DLinkFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for D-Link Power Plug.""" def __init__(self) -> None: """Initialize a D-Link Power Plug flow.""" self.ip_address: str | None = None - async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Handle dhcp discovery.""" await self.async_set_unique_id(discovery_info.macaddress) self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip}) @@ -41,7 +42,7 @@ class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm_discovery( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Allow the user to confirm adding the device.""" errors = {} if user_input is not None: @@ -74,7 +75,7 @@ class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" errors = {} if user_input is not None: diff --git a/homeassistant/components/dlna_dmr/config_flow.py b/homeassistant/components/dlna_dmr/config_flow.py index 1ad29c72c26..c98ed6e6dce 100644 --- a/homeassistant/components/dlna_dmr/config_flow.py +++ b/homeassistant/components/dlna_dmr/config_flow.py @@ -15,11 +15,15 @@ from async_upnp_client.profiles.profile import find_device_of_type from getmac import get_mac_address import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_DEVICE_ID, CONF_HOST, CONF_MAC, CONF_TYPE, CONF_URL from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import IntegrationError from homeassistant.helpers import config_validation as cv, device_registry as dr @@ -42,7 +46,7 @@ class ConnectError(IntegrationError): """Error occurred when trying to connect to a device.""" -class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DlnaDmrFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a DLNA DMR config flow. The Unique Device Name (UDN) of the DMR device is used as the unique_id for @@ -65,12 +69,12 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, - ) -> config_entries.OptionsFlow: + config_entry: ConfigEntry, + ) -> OptionsFlow: """Define the config flow to handle options.""" return DlnaDmrOptionsFlowHandler(config_entry) - async def async_step_user(self, user_input: FlowInput = None) -> FlowResult: + async def async_step_user(self, user_input: FlowInput = None) -> ConfigFlowResult: """Handle a flow initialized by the user. Let user choose from a list of found and unconfigured devices or to @@ -102,7 +106,7 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_show_form(step_id="user", data_schema=data_schema) - async def async_step_manual(self, user_input: FlowInput = None) -> FlowResult: + async def async_step_manual(self, user_input: FlowInput = None) -> ConfigFlowResult: """Manual URL entry by the user.""" LOGGER.debug("async_step_manual: user_input: %s", user_input) @@ -124,7 +128,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): step_id="manual", data_schema=data_schema, errors=errors ) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a flow initialized by SSDP discovery.""" if LOGGER.isEnabledFor(logging.DEBUG): LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info)) @@ -151,7 +157,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_confirm() - async def async_step_ignore(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_ignore( + self, user_input: Mapping[str, Any] + ) -> ConfigFlowResult: """Ignore this config flow, and add MAC address as secondary identifier. Not all DMR devices correctly implement the spec, so their UDN may @@ -185,7 +193,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): }, ) - async def async_step_unignore(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_unignore( + self, user_input: Mapping[str, Any] + ) -> ConfigFlowResult: """Rediscover previously ignored devices by their unique_id.""" LOGGER.debug("async_step_unignore: user_input: %s", user_input) self._udn = user_input["unique_id"] @@ -208,7 +218,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_confirm() - async def async_step_confirm(self, user_input: FlowInput = None) -> FlowResult: + async def async_step_confirm( + self, user_input: FlowInput = None + ) -> ConfigFlowResult: """Allow the user to confirm adding the device.""" LOGGER.debug("async_step_confirm: %s", user_input) @@ -256,7 +268,7 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if not self._mac and (host := urlparse(self._location).hostname): self._mac = await _async_get_mac_address(self.hass, host) - def _create_entry(self) -> FlowResult: + def _create_entry(self) -> ConfigFlowResult: """Create a config entry, assuming all required information is now known.""" LOGGER.debug( "_async_create_entry: location: %s, UDN: %s", self._location, self._udn @@ -333,19 +345,19 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return discoveries -class DlnaDmrOptionsFlowHandler(config_entries.OptionsFlow): +class DlnaDmrOptionsFlowHandler(OptionsFlow): """Handle a DLNA DMR options flow. Configures the single instance and updates the existing config entry. """ - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" errors: dict[str, str] = {} # Don't modify existing (read-only) options -- copy and update instead diff --git a/homeassistant/components/dlna_dms/config_flow.py b/homeassistant/components/dlna_dms/config_flow.py index e147055df05..0df2068ec71 100644 --- a/homeassistant/components/dlna_dms/config_flow.py +++ b/homeassistant/components/dlna_dms/config_flow.py @@ -9,10 +9,10 @@ from urllib.parse import urlparse from async_upnp_client.profiles.dlna import DmsDevice import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE_ID, CONF_HOST, CONF_URL -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from .const import CONF_SOURCE_ID, CONFIG_VERSION, DEFAULT_NAME, DOMAIN from .util import generate_source_id @@ -20,7 +20,7 @@ from .util import generate_source_id LOGGER = logging.getLogger(__name__) -class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DlnaDmsFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a DLNA DMS config flow. The Unique Service Name (USN) of the DMS device is used as the unique_id for @@ -39,7 +39,7 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user by listing unconfigured devices.""" LOGGER.debug("async_step_user: user_input: %s", user_input) @@ -65,7 +65,9 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): data_schema = vol.Schema({vol.Optional(CONF_HOST): vol.In(discovery_choices)}) return self.async_show_form(step_id="user", data_schema=data_schema) - async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: ssdp.SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a flow initialized by SSDP discovery.""" if LOGGER.isEnabledFor(logging.DEBUG): LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info)) @@ -101,7 +103,7 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Allow the user to confirm adding the device.""" if user_input is not None: return self._create_entry() @@ -109,7 +111,7 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._set_confirm_only() return self.async_show_form(step_id="confirm") - def _create_entry(self) -> FlowResult: + def _create_entry(self) -> ConfigFlowResult: """Create a config entry, assuming all required information is now known.""" LOGGER.debug( "_create_entry: name: %s, location: %s, USN: %s", diff --git a/homeassistant/components/dnsip/config_flow.py b/homeassistant/components/dnsip/config_flow.py index 6a1437d5159..b9e3c2a2dfe 100644 --- a/homeassistant/components/dnsip/config_flow.py +++ b/homeassistant/components/dnsip/config_flow.py @@ -9,10 +9,14 @@ import aiodns from aiodns.error import DNSError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_NAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import ( @@ -72,7 +76,7 @@ async def async_validate_hostname( return result -class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DnsIPConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for dnsip integration.""" VERSION = 1 @@ -80,14 +84,14 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> DnsIPOptionsFlowHandler: """Return Option handler.""" return DnsIPOptionsFlowHandler(config_entry) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} @@ -141,16 +145,16 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -class DnsIPOptionsFlowHandler(config_entries.OptionsFlow): +class DnsIPOptionsFlowHandler(OptionsFlow): """Handle a option config flow for dnsip integration.""" - def __init__(self, entry: config_entries.ConfigEntry) -> None: + def __init__(self, entry: ConfigEntry) -> None: """Initialize options flow.""" self.entry = entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" errors = {} if user_input is not None: diff --git a/homeassistant/components/doorbird/config_flow.py b/homeassistant/components/doorbird/config_flow.py index 983e56e64da..b91c072f85b 100644 --- a/homeassistant/components/doorbird/config_flow.py +++ b/homeassistant/components/doorbird/config_flow.py @@ -9,11 +9,16 @@ from doorbirdpy import DoorBird import requests import voluptuous as vol -from homeassistant import config_entries, core, exceptions from homeassistant.components import zeroconf +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult +from homeassistant.exceptions import HomeAssistantError from .const import CONF_EVENTS, DOMAIN, DOORBIRD_OUI from .util import get_mac_address_from_door_station_info @@ -39,9 +44,7 @@ def _check_device(device: DoorBird) -> tuple[tuple[bool, int], dict[str, Any]]: return device.ready(), device.info() -async def validate_input( - hass: core.HomeAssistant, data: dict[str, Any] -) -> dict[str, str]: +async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]: """Validate the user input allows us to connect.""" device = DoorBird(data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD]) try: @@ -75,7 +78,7 @@ async def async_verify_supported_device(hass: HomeAssistant, host: str) -> bool: return False -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DoorBirdConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for DoorBird.""" VERSION = 1 @@ -86,7 +89,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict[str, str] = {} if user_input is not None: @@ -101,7 +104,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Prepare configuration for a discovered doorbird device.""" macaddress = discovery_info.properties["macaddress"] @@ -152,22 +155,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Handle a option flow for doorbird.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle options flow.""" if user_input is not None: events = [event.strip() for event in user_input[CONF_EVENTS].split(",")] @@ -184,9 +187,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_form(step_id="init", data_schema=options_schema) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class InvalidAuth(exceptions.HomeAssistantError): +class InvalidAuth(HomeAssistantError): """Error to indicate there is invalid auth.""" diff --git a/homeassistant/components/dormakaba_dkey/config_flow.py b/homeassistant/components/dormakaba_dkey/config_flow.py index f03861d015e..c2cdf1854e2 100644 --- a/homeassistant/components/dormakaba_dkey/config_flow.py +++ b/homeassistant/components/dormakaba_dkey/config_flow.py @@ -9,14 +9,13 @@ from bleak import BleakError from py_dormakaba_dkey import DKEYLock, device_filter, errors as dkey_errors import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.bluetooth import ( BluetoothServiceInfoBleak, async_discovered_service_info, async_last_service_info, ) +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import CONF_ASSOCIATION_DATA, DOMAIN @@ -29,12 +28,12 @@ STEP_ASSOCIATE_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Dormakaba dKey.""" VERSION = 1 - _reauth_entry: config_entries.ConfigEntry | None = None + _reauth_entry: ConfigEntry | None = None def __init__(self) -> None: """Initialize the config flow.""" @@ -46,7 +45,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user step to pick discovered device.""" errors: dict[str, str] = {} @@ -92,7 +91,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the Bluetooth discovery step.""" await self.async_set_unique_id(discovery_info.address) self._abort_if_unique_id_configured() @@ -103,7 +102,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle bluetooth confirm step.""" # mypy is not aware that we can't get here without having these set already assert self._discovery_info is not None @@ -117,7 +116,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_associate() - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauthorization request.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -126,7 +127,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle reauthorization flow.""" errors = {} reauth_entry = self._reauth_entry @@ -149,7 +150,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_associate( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle associate step.""" # mypy is not aware that we can't get here without having these set already assert self._discovery_info is not None diff --git a/homeassistant/components/dremel_3d_printer/config_flow.py b/homeassistant/components/dremel_3d_printer/config_flow.py index 6fa4d2e0a5b..f9dc96b8287 100644 --- a/homeassistant/components/dremel_3d_printer/config_flow.py +++ b/homeassistant/components/dremel_3d_printer/config_flow.py @@ -8,9 +8,8 @@ from dremel3dpy import Dremel3DPrinter from requests.exceptions import ConnectTimeout, HTTPError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import DOMAIN, LOGGER @@ -20,14 +19,14 @@ def _schema_with_defaults(host: str = "") -> vol.Schema: return vol.Schema({vol.Required(CONF_HOST, default=host): cv.string}) -class Dremel3DPrinterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class Dremel3DPrinterConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Dremel 3D Printer.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} diff --git a/homeassistant/components/drop_connect/config_flow.py b/homeassistant/components/drop_connect/config_flow.py index a2b93ad1da1..c315616ceba 100644 --- a/homeassistant/components/drop_connect/config_flow.py +++ b/homeassistant/components/drop_connect/config_flow.py @@ -6,8 +6,7 @@ from typing import TYPE_CHECKING, Any from dropmqttapi.discovery import DropDiscovery -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.helpers.service_info.mqtt import MqttServiceInfo from .const import ( @@ -26,14 +25,16 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class FlowHandler(ConfigFlow, domain=DOMAIN): """Handle DROP config flow.""" VERSION = 1 _drop_discovery: DropDiscovery | None = None - async def async_step_mqtt(self, discovery_info: MqttServiceInfo) -> FlowResult: + async def async_step_mqtt( + self, discovery_info: MqttServiceInfo + ) -> ConfigFlowResult: """Handle a flow initialized by MQTT discovery.""" # Abort if the topic does not match our discovery topic or the payload is empty. @@ -64,7 +65,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm the setup.""" if TYPE_CHECKING: assert self._drop_discovery is not None @@ -93,6 +94,6 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" return self.async_abort(reason="not_supported") diff --git a/homeassistant/components/dsmr/config_flow.py b/homeassistant/components/dsmr/config_flow.py index a38326c1346..422ae285b4c 100644 --- a/homeassistant/components/dsmr/config_flow.py +++ b/homeassistant/components/dsmr/config_flow.py @@ -17,11 +17,15 @@ import serial import serial.tools.list_ports import voluptuous as vol -from homeassistant import config_entries, core, exceptions -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_HOST, CONF_PORT, CONF_PROTOCOL, CONF_TYPE -from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError from .const import ( CONF_DSMR_VERSION, @@ -75,7 +79,7 @@ class DSMRConnection: return identifier return None - async def validate_connect(self, hass: core.HomeAssistant) -> bool: + async def validate_connect(self, hass: HomeAssistant) -> bool: """Test if we can validate connection with the device.""" def update_telegram(telegram: dict[str, DSMRObject]) -> None: @@ -131,7 +135,7 @@ class DSMRConnection: async def _validate_dsmr_connection( - hass: core.HomeAssistant, data: dict[str, Any], protocol: str + hass: HomeAssistant, data: dict[str, Any], protocol: str ) -> dict[str, str | None]: """Validate the user input allows us to connect.""" conn = DSMRConnection( @@ -157,7 +161,7 @@ async def _validate_dsmr_connection( } -class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DSMRFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for DSMR.""" VERSION = 1 @@ -172,7 +176,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when user initializes a integration.""" if user_input is not None: user_selection = user_input[CONF_TYPE] @@ -188,7 +192,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_setup_network( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when setting up network configuration.""" errors: dict[str, str] = {} if user_input is not None: @@ -213,7 +217,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_setup_serial( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when setting up serial configuration.""" errors: dict[str, str] = {} if user_input is not None: @@ -257,7 +261,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_setup_serial_manual_path( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Select path manually.""" if user_input is not None: validate_data = { @@ -303,7 +307,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return data -class DSMROptionFlowHandler(config_entries.OptionsFlow): +class DSMROptionFlowHandler(OptionsFlow): """Handle options.""" def __init__(self, entry: ConfigEntry) -> None: @@ -312,7 +316,7 @@ class DSMROptionFlowHandler(config_entries.OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) @@ -344,9 +348,9 @@ def get_serial_by_id(dev_path: str) -> str: return dev_path -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class CannotCommunicate(exceptions.HomeAssistantError): +class CannotCommunicate(HomeAssistantError): """Error to indicate we cannot connect.""" diff --git a/homeassistant/components/dsmr_reader/config_flow.py b/homeassistant/components/dsmr_reader/config_flow.py index 44ff6663654..87b0e562efd 100644 --- a/homeassistant/components/dsmr_reader/config_flow.py +++ b/homeassistant/components/dsmr_reader/config_flow.py @@ -4,8 +4,8 @@ from __future__ import annotations from collections.abc import Awaitable from typing import Any +from homeassistant.config_entries import ConfigFlowResult from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler from .const import DOMAIN @@ -27,7 +27,7 @@ class DsmrReaderFlowHandler(DiscoveryFlowHandler[Awaitable[bool]], domain=DOMAIN async def async_step_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm setup.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/dunehd/config_flow.py b/homeassistant/components/dunehd/config_flow.py index fac2e245633..718d5b4ee6f 100644 --- a/homeassistant/components/dunehd/config_flow.py +++ b/homeassistant/components/dunehd/config_flow.py @@ -6,15 +6,15 @@ from typing import Any from pdunehd import DuneHDPlayer import voluptuous as vol -from homeassistant import config_entries, exceptions +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST -from homeassistant.data_entry_flow import FlowResult +from homeassistant.exceptions import HomeAssistantError from homeassistant.util.network import is_host_valid from .const import DOMAIN -class DuneHDConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DuneHDConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Dune HD integration.""" VERSION = 1 @@ -28,7 +28,7 @@ class DuneHDConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} @@ -63,9 +63,9 @@ class DuneHDConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return host in existing_hosts -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" -class AlreadyConfigured(exceptions.HomeAssistantError): +class AlreadyConfigured(HomeAssistantError): """Error to indicate device is already configured.""" diff --git a/homeassistant/components/duotecno/config_flow.py b/homeassistant/components/duotecno/config_flow.py index 6f08b025835..069988dbb17 100644 --- a/homeassistant/components/duotecno/config_flow.py +++ b/homeassistant/components/duotecno/config_flow.py @@ -8,9 +8,8 @@ from duotecno.controller import PyDuotecno from duotecno.exceptions import InvalidPassword import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -25,14 +24,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class DuoTecnoConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for duotecno.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/dwd_weather_warnings/config_flow.py b/homeassistant/components/dwd_weather_warnings/config_flow.py index 1e0bb797c7a..5076dbae187 100644 --- a/homeassistant/components/dwd_weather_warnings/config_flow.py +++ b/homeassistant/components/dwd_weather_warnings/config_flow.py @@ -7,8 +7,7 @@ from typing import Any from dwdwfsapi import DwdWeatherWarningsAPI import voluptuous as vol -from homeassistant.config_entries import ConfigFlow -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult import homeassistant.helpers.config_validation as cv from .const import CONF_REGION_IDENTIFIER, DOMAIN @@ -21,7 +20,7 @@ class DwdWeatherWarningsConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors: dict = {} diff --git a/homeassistant/components/dynalite/config_flow.py b/homeassistant/components/dynalite/config_flow.py index 7cced80c97e..2bb4327f517 100644 --- a/homeassistant/components/dynalite/config_flow.py +++ b/homeassistant/components/dynalite/config_flow.py @@ -5,10 +5,9 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue @@ -17,7 +16,7 @@ from .const import DEFAULT_PORT, DOMAIN, LOGGER from .convert_config import convert_config -class DynaliteFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class DynaliteFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Dynalite config flow.""" VERSION = 1 @@ -26,7 +25,7 @@ class DynaliteFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Initialize the Dynalite flow.""" self.host = None - async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult: + async def async_step_import(self, import_info: dict[str, Any]) -> ConfigFlowResult: """Import a new bridge as a config entry.""" LOGGER.debug("Starting async_step_import (deprecated) - %s", import_info) # Raise an issue that this is deprecated and has been imported @@ -60,7 +59,7 @@ class DynaliteFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when user initializes a integration.""" if user_input is not None: return await self._try_create(user_input) @@ -73,7 +72,7 @@ class DynaliteFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_show_form(step_id="user", data_schema=schema) - async def _try_create(self, info: dict[str, Any]) -> FlowResult: + async def _try_create(self, info: dict[str, Any]) -> ConfigFlowResult: """Try to connect and if successful, create entry.""" host = info[CONF_HOST] configured_hosts = [ diff --git a/tests/components/aussie_broadband/test_init.py b/tests/components/aussie_broadband/test_init.py index e16a721f5dc..9ac7f6628b4 100644 --- a/tests/components/aussie_broadband/test_init.py +++ b/tests/components/aussie_broadband/test_init.py @@ -22,7 +22,7 @@ async def test_unload(hass: HomeAssistant) -> None: async def test_auth_failure(hass: HomeAssistant) -> None: """Test init with an authentication failure.""" with patch( - "homeassistant.components.aussie_broadband.config_flow.ConfigFlow.async_step_reauth", + "homeassistant.components.aussie_broadband.config_flow.AussieBroadbandConfigFlow.async_step_reauth", return_value={ "type": data_entry_flow.FlowResultType.FORM, "flow_id": "mock_flow",