From 52e7912caf3edfae21cf4341487dfe9e019dcf73 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 29 Feb 2024 20:08:46 +0100 Subject: [PATCH] Migrate integrations i-m to generic flowhandler (#111863) --- .../components/ialarm/config_flow.py | 7 ++- .../components/iaqualink/config_flow.py | 7 +-- .../components/ibeacon/config_flow.py | 22 +++++--- .../components/icloud/config_flow.py | 11 ++-- .../components/idasen_desk/config_flow.py | 9 ++- homeassistant/components/imap/config_flow.py | 27 +++++---- .../components/improv_ble/config_flow.py | 30 +++++----- .../components/inkbird/config_flow.py | 9 ++- .../components/insteon/config_flow.py | 43 +++++++++------ .../components/intellifire/config_flow.py | 21 ++++--- .../components/iotawatt/config_flow.py | 14 ++--- homeassistant/components/ipma/config_flow.py | 5 +- homeassistant/components/ipp/config_flow.py | 11 ++-- homeassistant/components/iqvia/config_flow.py | 7 +-- .../islamic_prayer_times/config_flow.py | 20 ++++--- homeassistant/components/iss/config_flow.py | 22 +++++--- .../components/isy994/config_flow.py | 55 +++++++++++-------- .../components/jellyfin/config_flow.py | 15 ++--- .../components/juicenet/config_flow.py | 4 +- .../components/justnimbus/config_flow.py | 13 +++-- .../components/jvc_projector/config_flow.py | 11 ++-- .../components/kaleidescape/config_flow.py | 15 +++-- .../components/keenetic_ndms2/config_flow.py | 23 +++++--- .../components/kegtron/config_flow.py | 9 ++- .../components/keymitt_ble/config_flow.py | 11 ++-- .../components/kitchen_sink/config_flow.py | 7 +-- .../components/kmtronic/config_flow.py | 19 ++++--- homeassistant/components/knx/config_flow.py | 47 +++++++++------- homeassistant/components/kodi/config_flow.py | 20 +++---- .../components/konnected/config_flow.py | 20 ++++--- .../kostal_plenticore/config_flow.py | 4 +- .../components/kraken/config_flow.py | 20 ++++--- .../components/lacrosse_view/config_flow.py | 15 ++--- .../components/lamarzocco/config_flow.py | 13 +++-- .../components/lametric/config_flow.py | 32 +++++++---- .../landisgyr_heat_meter/config_flow.py | 9 ++- .../components/lastfm/config_flow.py | 8 +-- .../components/launch_library/config_flow.py | 7 +-- .../components/laundrify/config_flow.py | 13 +++-- homeassistant/components/lcn/config_flow.py | 18 +++--- .../components/ld2410_ble/config_flow.py | 9 ++- .../components/leaone/config_flow.py | 5 +- .../components/led_ble/config_flow.py | 9 ++- .../components/lg_soundbar/config_flow.py | 7 +-- .../components/lidarr/config_flow.py | 11 ++-- homeassistant/components/lifx/config_flow.py | 23 ++++---- .../linear_garage_door/config_flow.py | 15 ++--- .../components/litejet/config_flow.py | 20 ++++--- .../components/litterrobot/config_flow.py | 13 +++-- .../components/livisi/config_flow.py | 9 ++- .../components/local_calendar/config_flow.py | 7 +-- .../components/local_ip/config_flow.py | 5 +- .../components/local_todo/config_flow.py | 7 +-- .../components/logi_circle/config_flow.py | 4 +- .../components/lookin/config_flow.py | 11 ++-- homeassistant/components/loqed/config_flow.py | 9 ++- .../components/luftdaten/config_flow.py | 9 ++- .../components/lupusec/config_flow.py | 7 ++- .../components/lutron/config_flow.py | 9 +-- .../components/lutron_caseta/config_flow.py | 9 ++- homeassistant/components/lyric/config_flow.py | 10 ++-- .../components/matter/config_flow.py | 30 +++++----- .../components/meater/config_flow.py | 15 ++--- .../components/medcom_ble/config_flow.py | 12 ++-- .../components/melcloud/config_flow.py | 19 ++++--- .../components/melnor/config_flow.py | 15 +++-- homeassistant/components/met/config_flow.py | 24 ++++---- .../components/met_eireann/config_flow.py | 7 +-- .../components/meteo_france/config_flow.py | 12 ++-- .../components/meteoclimatic/config_flow.py | 4 +- .../components/metoffice/config_flow.py | 15 +++-- .../components/microbees/config_flow.py | 11 ++-- .../components/mikrotik/config_flow.py | 28 ++++++---- homeassistant/components/mill/config_flow.py | 4 +- .../minecraft_server/config_flow.py | 7 +-- homeassistant/components/mjpeg/config_flow.py | 12 ++-- homeassistant/components/moat/config_flow.py | 9 ++- .../components/mobile_app/config_flow.py | 4 +- .../components/modem_callerid/config_flow.py | 13 +++-- .../components/modern_forms/config_flow.py | 15 +++-- .../moehlenhoff_alpha2/config_flow.py | 5 +- .../components/monoprice/config_flow.py | 24 ++++---- homeassistant/components/moon/config_flow.py | 5 +- .../components/mopeka/config_flow.py | 9 ++- .../components/motion_blinds/config_flow.py | 28 ++++++---- .../components/motioneye/config_flow.py | 18 +++--- .../components/motionmount/config_flow.py | 23 +++++--- homeassistant/components/mqtt/config_flow.py | 24 +++++--- .../components/mullvad/config_flow.py | 7 +-- .../components/mutesync/config_flow.py | 7 +-- homeassistant/components/myq/config_flow.py | 4 +- .../components/mysensors/config_flow.py | 18 +++--- .../components/mystrom/config_flow.py | 7 +-- .../components/myuplink/config_flow.py | 11 ++-- 94 files changed, 715 insertions(+), 612 deletions(-) diff --git a/homeassistant/components/ialarm/config_flow.py b/homeassistant/components/ialarm/config_flow.py index a894a6f4e11..0681160c741 100644 --- a/homeassistant/components/ialarm/config_flow.py +++ b/homeassistant/components/ialarm/config_flow.py @@ -4,8 +4,9 @@ import logging from pyialarm import IAlarm import voluptuous as vol -from homeassistant import config_entries, core +from homeassistant.config_entries import ConfigFlow from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.core import HomeAssistant from .const import DEFAULT_PORT, DOMAIN @@ -19,12 +20,12 @@ DATA_SCHEMA = vol.Schema( ) -async def _get_device_mac(hass: core.HomeAssistant, host, port): +async def _get_device_mac(hass: HomeAssistant, host, port): ialarm = IAlarm(host, port) return await hass.async_add_executor_job(ialarm.get_mac) -class IAlarmConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IAlarmConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Antifurto365 iAlarm.""" VERSION = 1 diff --git a/homeassistant/components/iaqualink/config_flow.py b/homeassistant/components/iaqualink/config_flow.py index 0dfc60f2fee..abacdf7a42f 100644 --- a/homeassistant/components/iaqualink/config_flow.py +++ b/homeassistant/components/iaqualink/config_flow.py @@ -11,21 +11,20 @@ from iaqualink.exception import ( ) 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 DOMAIN -class AqualinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AqualinkFlowHandler(ConfigFlow, domain=DOMAIN): """Aqualink config flow.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow start.""" # Supporting a single account. entries = self._async_current_entries() diff --git a/homeassistant/components/ibeacon/config_flow.py b/homeassistant/components/ibeacon/config_flow.py index c7d6c358a29..c315090ef3d 100644 --- a/homeassistant/components/ibeacon/config_flow.py +++ b/homeassistant/components/ibeacon/config_flow.py @@ -6,23 +6,27 @@ from uuid import UUID import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import bluetooth +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 .const import CONF_ALLOW_NAMELESS_UUIDS, DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IBeaconConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for iBeacon Tracker.""" 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") @@ -38,20 +42,20 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlow: """Get the options flow for this handler.""" - return OptionsFlow(config_entry) + return IBeaconOptionsFlow(config_entry) -class OptionsFlow(config_entries.OptionsFlow): +class IBeaconOptionsFlow(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 - async def async_step_init(self, user_input: dict | None = None) -> FlowResult: + async def async_step_init(self, user_input: dict | None = None) -> ConfigFlowResult: """Manage the options.""" errors = {} diff --git a/homeassistant/components/icloud/config_flow.py b/homeassistant/components/icloud/config_flow.py index 4be5487f755..5a46ab3b4f3 100644 --- a/homeassistant/components/icloud/config_flow.py +++ b/homeassistant/components/icloud/config_flow.py @@ -15,9 +15,8 @@ from pyicloud.exceptions import ( ) 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.storage import Store from .const import ( @@ -38,7 +37,7 @@ CONF_VERIFICATION_CODE = "verification_code" _LOGGER = logging.getLogger(__name__) -class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class IcloudFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a iCloud config flow.""" VERSION = 1 @@ -178,7 +177,9 @@ class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self._validate_and_create_entry(user_input, "user") - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Initialise re-authentication.""" # Store existing entry data so it can be used later and set unique ID # so existing config entry can be updated @@ -189,7 +190,7 @@ class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Update password for a config entry that can't authenticate.""" if user_input is None: return self._show_setup_form(step_id="reauth_confirm") diff --git a/homeassistant/components/idasen_desk/config_flow.py b/homeassistant/components/idasen_desk/config_flow.py index 80282ce0271..8fec40cde80 100644 --- a/homeassistant/components/idasen_desk/config_flow.py +++ b/homeassistant/components/idasen_desk/config_flow.py @@ -10,20 +10,19 @@ from idasen_ha import Desk from idasen_ha.errors import AuthFailedError 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 FlowResult from .const import DOMAIN, EXPECTED_SERVICE_UUID _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IdasenDeskConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Idasen Desk integration.""" VERSION = 1 @@ -35,7 +34,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() @@ -49,7 +48,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] = {} diff --git a/homeassistant/components/imap/config_flow.py b/homeassistant/components/imap/config_flow.py index 15b52ce6333..c4df769384e 100644 --- a/homeassistant/components/imap/config_flow.py +++ b/homeassistant/components/imap/config_flow.py @@ -8,10 +8,15 @@ from typing import Any from aioimaplib import AioImapException import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlowWithConfigEntry, +) from homeassistant.const import CONF_PASSWORD, CONF_PORT, CONF_USERNAME, CONF_VERIFY_SSL from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from homeassistant.helpers import config_validation as cv from homeassistant.helpers.selector import ( BooleanSelector, @@ -119,15 +124,15 @@ async def validate_input( return errors -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IMAPConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for imap.""" VERSION = 1 - _reauth_entry: config_entries.ConfigEntry | None + _reauth_entry: ConfigEntry | None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" schema = CONFIG_SCHEMA @@ -152,7 +157,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): schema = self.add_suggested_values_to_schema(schema, user_input) 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: """Perform reauth upon an API authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -161,7 +168,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 @@ -188,18 +195,18 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlow: """Get the options flow for this handler.""" return OptionsFlow(config_entry) -class OptionsFlow(config_entries.OptionsFlowWithConfigEntry): +class OptionsFlow(OptionsFlowWithConfigEntry): """Option flow handler.""" async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" errors: dict[str, str] | None = None entry_data: dict[str, Any] = dict(self._config_entry.data) diff --git a/homeassistant/components/improv_ble/config_flow.py b/homeassistant/components/improv_ble/config_flow.py index 6f940f91946..a7d3c2cf000 100644 --- a/homeassistant/components/improv_ble/config_flow.py +++ b/homeassistant/components/improv_ble/config_flow.py @@ -19,11 +19,11 @@ from improv_ble_client import ( ) import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import bluetooth +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS from homeassistant.core import callback -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from .const import DOMAIN @@ -47,7 +47,7 @@ class Credentials: ssid: str -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class ImprovBLEConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Improv via BLE.""" VERSION = 1 @@ -55,9 +55,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): _authorize_task: asyncio.Task | None = None _can_identify: bool | None = None _credentials: Credentials | None = None - _provision_result: FlowResult | None = None + _provision_result: ConfigFlowResult | None = None _provision_task: asyncio.Task | None = None - _reauth_entry: config_entries.ConfigEntry | None = None + _reauth_entry: ConfigEntry | None = None _remove_bluetooth_callback: Callable[[], None] | None = None _unsub: Callable[[], None] | None = None @@ -71,7 +71,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] = {} @@ -158,7 +158,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: bluetooth.BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the Bluetooth discovery step.""" self._discovery_info = discovery_info @@ -181,7 +181,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 @@ -198,7 +198,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_start_improv( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Start improv flow. If the device supports identification, show a menu, if it does not, @@ -220,7 +220,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_main_menu() return await self.async_step_provision() - async def async_step_main_menu(self, _: None = None) -> FlowResult: + async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult: """Show the main menu.""" return self.async_show_menu( step_id="main_menu", @@ -232,7 +232,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_identify( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle identify step.""" # mypy is not aware that we can't get here without having these set already assert self._device is not None @@ -247,7 +247,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_provision( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle provision step.""" # mypy is not aware that we can't get here without having these set already assert self._device is not None @@ -272,7 +272,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_do_provision( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Execute provisioning.""" async def _do_provision() -> None: @@ -339,7 +339,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_provision_done( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the result of the provision step.""" # mypy is not aware that we can't get here without having these set already assert self._provision_result is not None @@ -350,7 +350,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_authorize( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle authorize step.""" # mypy is not aware that we can't get here without having these set already assert self._device is not None diff --git a/homeassistant/components/inkbird/config_flow.py b/homeassistant/components/inkbird/config_flow.py index c63ad7e09d8..19c27dd5757 100644 --- a/homeassistant/components/inkbird/config_flow.py +++ b/homeassistant/components/inkbird/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 INKBIRDConfigFlow(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 INKBIRDConfigFlow(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 INKBIRDConfigFlow(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/insteon/config_flow.py b/homeassistant/components/insteon/config_flow.py index 36e977f6db0..66a131207bf 100644 --- a/homeassistant/components/insteon/config_flow.py +++ b/homeassistant/components/insteon/config_flow.py @@ -5,8 +5,14 @@ import logging from pyinsteon import async_close, async_connect, devices -from homeassistant import config_entries from homeassistant.components import dhcp, usb +from homeassistant.config_entries import ( + DEFAULT_DISCOVERY_UNIQUE_ID, + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import ( CONF_ADDRESS, CONF_DEVICE, @@ -17,7 +23,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.helpers.dispatcher import async_dispatcher_send @@ -106,7 +111,7 @@ def _remove_x10(device, options): return new_options, housecode, unitcode -class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class InsteonFlowHandler(ConfigFlow, domain=DOMAIN): """Insteon config flow handler.""" _device_path: str | None = None @@ -116,7 +121,7 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> InsteonOptionsFlowHandler: """Define the config flow to handle options.""" return InsteonOptionsFlowHandler(config_entry) @@ -185,7 +190,9 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): step_id=step_id, data_schema=data_schema, errors=errors ) - async def async_step_usb(self, discovery_info: usb.UsbServiceInfo) -> FlowResult: + async def async_step_usb( + self, discovery_info: usb.UsbServiceInfo + ) -> ConfigFlowResult: """Handle USB discovery.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -203,10 +210,10 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self.context["title_placeholders"] = { CONF_NAME: f"Insteon PLM {self._device_name}" } - await self.async_set_unique_id(config_entries.DEFAULT_DISCOVERY_UNIQUE_ID) + await self.async_set_unique_id(DEFAULT_DISCOVERY_UNIQUE_ID) return await self.async_step_confirm_usb() - async def async_step_confirm_usb(self, user_input=None) -> FlowResult: + async def async_step_confirm_usb(self, user_input=None) -> ConfigFlowResult: """Confirm a USB discovery.""" if user_input is not None: return await self.async_step_plm({CONF_DEVICE: self._device_path}) @@ -216,7 +223,9 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): description_placeholders={CONF_NAME: self._device_name}, ) - async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Handle a DHCP discovery.""" self.discovered_conf = {CONF_HOST: discovery_info.ip} self.context["title_placeholders"] = { @@ -226,14 +235,14 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_user() -class InsteonOptionsFlowHandler(config_entries.OptionsFlow): +class InsteonOptionsFlowHandler(OptionsFlow): """Handle an Insteon options flow.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Init the InsteonOptionsFlowHandler class.""" self.config_entry = config_entry - async def async_step_init(self, user_input=None) -> FlowResult: + async def async_step_init(self, user_input=None) -> ConfigFlowResult: """Init the options config flow.""" menu_options = [STEP_ADD_OVERRIDE, STEP_ADD_X10] @@ -250,7 +259,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_menu(step_id="init", menu_options=menu_options) - async def async_step_change_hub_config(self, user_input=None) -> FlowResult: + async def async_step_change_hub_config(self, user_input=None) -> ConfigFlowResult: """Change the Hub configuration.""" errors = {} if user_input is not None: @@ -276,7 +285,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): step_id=STEP_CHANGE_HUB_CONFIG, data_schema=data_schema, errors=errors ) - async def async_step_change_plm_config(self, user_input=None) -> FlowResult: + async def async_step_change_plm_config(self, user_input=None) -> ConfigFlowResult: """Change the PLM configuration.""" errors = {} if user_input is not None: @@ -299,7 +308,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): step_id=STEP_CHANGE_PLM_CONFIG, data_schema=data_schema, errors=errors ) - async def async_step_add_override(self, user_input=None) -> FlowResult: + async def async_step_add_override(self, user_input=None) -> ConfigFlowResult: """Add a device override.""" errors = {} if user_input is not None: @@ -315,7 +324,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): step_id=STEP_ADD_OVERRIDE, data_schema=data_schema, errors=errors ) - async def async_step_add_x10(self, user_input=None) -> FlowResult: + async def async_step_add_x10(self, user_input=None) -> ConfigFlowResult: """Add an X10 device.""" errors: dict[str, str] = {} if user_input is not None: @@ -328,7 +337,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): step_id=STEP_ADD_X10, data_schema=data_schema, errors=errors ) - async def async_step_remove_override(self, user_input=None) -> FlowResult: + async def async_step_remove_override(self, user_input=None) -> ConfigFlowResult: """Remove a device override.""" errors: dict[str, str] = {} options = self.config_entry.options @@ -346,7 +355,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow): step_id=STEP_REMOVE_OVERRIDE, data_schema=data_schema, errors=errors ) - async def async_step_remove_x10(self, user_input=None) -> FlowResult: + async def async_step_remove_x10(self, user_input=None) -> ConfigFlowResult: """Remove an X10 device.""" errors: dict[str, str] = {} options = self.config_entry.options diff --git a/homeassistant/components/intellifire/config_flow.py b/homeassistant/components/intellifire/config_flow.py index 6a061b40bcc..17d442428e7 100644 --- a/homeassistant/components/intellifire/config_flow.py +++ b/homeassistant/components/intellifire/config_flow.py @@ -11,10 +11,9 @@ from intellifire4py.exceptions import LoginException from intellifire4py.intellifire import IntellifireAPICloud, IntellifireAPILocal import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.dhcp import DhcpServiceInfo +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from .const import CONF_USER_ID, DOMAIN, LOGGER @@ -46,7 +45,7 @@ async def validate_host_input(host: str, dhcp_mode: bool = False) -> str: return serial -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IntelliFireConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for IntelliFire.""" VERSION = 1 @@ -107,7 +106,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_api_config( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Configure API access.""" errors = {} @@ -151,7 +150,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="api_config", errors=errors, data_schema=control_schema ) - async def _async_validate_ip_and_continue(self, host: str) -> FlowResult: + async def _async_validate_ip_and_continue(self, host: str) -> ConfigFlowResult: """Validate local config and continue.""" self._async_abort_entries_match({CONF_HOST: host}) self._serial = await validate_host_input(host) @@ -181,7 +180,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_pick_device( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Pick which device to configure.""" errors = {} LOGGER.debug("STEP: pick_device") @@ -210,7 +209,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Start the user flow.""" # Launch fireplaces discovery @@ -222,7 +221,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): LOGGER.debug("Running Step: manual_device_entry") return await self.async_step_manual_device_entry() - async def async_step_reauth(self, 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.""" LOGGER.debug("STEP: reauth") entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) @@ -237,7 +238,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.context["title_placeholders"] = placeholders return await self.async_step_api_config() - async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: DhcpServiceInfo + ) -> ConfigFlowResult: """Handle DHCP Discovery.""" # Run validation logic on ip diff --git a/homeassistant/components/iotawatt/config_flow.py b/homeassistant/components/iotawatt/config_flow.py index 9ec860ea76a..6b7b86b73af 100644 --- a/homeassistant/components/iotawatt/config_flow.py +++ b/homeassistant/components/iotawatt/config_flow.py @@ -6,8 +6,10 @@ import logging from iotawattpy.iotawatt import Iotawatt import voluptuous as vol -from homeassistant import config_entries, core, exceptions +from homeassistant.config_entries import ConfigFlow from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import httpx_client from .const import CONNECTION_ERRORS, DOMAIN @@ -15,9 +17,7 @@ from .const import CONNECTION_ERRORS, DOMAIN _LOGGER = logging.getLogger(__name__) -async def validate_input( - hass: core.HomeAssistant, data: dict[str, str] -) -> dict[str, str]: +async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str, str]: """Validate the user input allows us to connect.""" iotawatt = Iotawatt( "", @@ -40,7 +40,7 @@ async def validate_input( return {} -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IOTaWattConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for iotawatt.""" VERSION = 1 @@ -99,9 +99,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_create_entry(title=data[CONF_HOST], data=data) -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/ipma/config_flow.py b/homeassistant/components/ipma/config_flow.py index cdea88bdbc0..cf468c9013a 100644 --- a/homeassistant/components/ipma/config_flow.py +++ b/homeassistant/components/ipma/config_flow.py @@ -7,9 +7,8 @@ from pyipma.api import IPMA_API from pyipma.location import Location import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import 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 @@ -25,7 +24,7 @@ class IpmaFlowHandler(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 = {} diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index dfe6c0b2127..334fb5d7690 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -16,7 +16,7 @@ from pyipp import ( 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, @@ -26,7 +26,6 @@ from homeassistant.const import ( CONF_VERIFY_SSL, ) 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_BASE_PATH, CONF_SERIAL, DOMAIN @@ -65,7 +64,7 @@ class IPPFlowHandler(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() @@ -104,7 +103,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.host @@ -190,7 +189,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a confirmation flow initiated by zeroconf.""" if user_input is None: return self.async_show_form( @@ -204,7 +203,7 @@ class IPPFlowHandler(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/iqvia/config_flow.py b/homeassistant/components/iqvia/config_flow.py index 32ce64014d7..d293aedd7b2 100644 --- a/homeassistant/components/iqvia/config_flow.py +++ b/homeassistant/components/iqvia/config_flow.py @@ -7,14 +7,13 @@ from pyiqvia import Client from pyiqvia.errors import InvalidZipError import voluptuous as vol -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.helpers import aiohttp_client from .const import CONF_ZIP_CODE, DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class IqviaConfigFlow(ConfigFlow, domain=DOMAIN): """Handle an IQVIA config flow.""" VERSION = 1 @@ -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: + ) -> ConfigFlowResult: """Handle the start of the config flow.""" if not user_input: return self.async_show_form(step_id="user", data_schema=self.data_schema) diff --git a/homeassistant/components/islamic_prayer_times/config_flow.py b/homeassistant/components/islamic_prayer_times/config_flow.py index 73696572593..766163a9b0d 100644 --- a/homeassistant/components/islamic_prayer_times/config_flow.py +++ b/homeassistant/components/islamic_prayer_times/config_flow.py @@ -7,10 +7,14 @@ from prayer_times_calculator import InvalidResponseError, PrayerTimesCalculator from requests.exceptions import ConnectionError as ConnError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE, CONF_NAME from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.selector import ( LocationSelector, SelectSelector, @@ -58,7 +62,7 @@ async def async_validate_location( return errors -class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class IslamicPrayerFlowHandler(ConfigFlow, domain=DOMAIN): """Handle the Islamic Prayer config flow.""" VERSION = 1 @@ -67,14 +71,14 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> IslamicPrayerOptionsFlowHandler: """Get the options flow for this handler.""" return IslamicPrayerOptionsFlowHandler(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 = {} @@ -111,16 +115,16 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) -class IslamicPrayerOptionsFlowHandler(config_entries.OptionsFlow): +class IslamicPrayerOptionsFlowHandler(OptionsFlow): """Handle Islamic Prayer client 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 async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/iss/config_flow.py b/homeassistant/components/iss/config_flow.py index f8ebd9db723..80644698239 100644 --- a/homeassistant/components/iss/config_flow.py +++ b/homeassistant/components/iss/config_flow.py @@ -2,15 +2,19 @@ import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_SHOW_ON_MAP from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import DEFAULT_NAME, DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class ISSConfigFlow(ConfigFlow, domain=DOMAIN): """Config flow for iss component.""" VERSION = 1 @@ -18,12 +22,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, - ) -> config_entries.OptionsFlow: + config_entry: ConfigEntry, + ) -> OptionsFlow: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) - async def async_step_user(self, user_input=None) -> FlowResult: + async def async_step_user(self, user_input=None) -> ConfigFlowResult: """Handle a flow initialized by the user.""" # Check if already configured if self._async_current_entries(): @@ -39,15 +43,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_show_form(step_id="user") -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Config flow options handler for iss.""" - 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=None) -> FlowResult: + async def async_step_init(self, user_input=None) -> ConfigFlowResult: """Manage the options.""" if user_input is not None: self.options.update(user_input) diff --git a/homeassistant/components/isy994/config_flow.py b/homeassistant/components/isy994/config_flow.py index 2cdfd1df16d..658f7204d41 100644 --- a/homeassistant/components/isy994/config_flow.py +++ b/homeassistant/components/isy994/config_flow.py @@ -13,11 +13,18 @@ from pyisy.configuration import Configuration from pyisy.connection import Connection import voluptuous as vol -from homeassistant import config_entries, core, exceptions from homeassistant.components import dhcp, ssdp +from homeassistant.config_entries import ( + SOURCE_IGNORE, + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME -from homeassistant.core import callback -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.core import HomeAssistant, callback +from homeassistant.data_entry_flow import AbortFlow +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import aiohttp_client from .const import ( @@ -58,9 +65,7 @@ def _data_schema(schema_input: dict[str, str]) -> 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. @@ -118,7 +123,7 @@ async def validate_input( } -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class Isy994ConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Universal Devices ISY/IoX.""" VERSION = 1 @@ -126,19 +131,19 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Initialize the ISY/IoX config flow.""" self.discovered_conf: dict[str, str] = {} - self._existing_entry: config_entries.ConfigEntry | None = None + self._existing_entry: ConfigEntry | None = None @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, - ) -> config_entries.OptionsFlow: + config_entry: ConfigEntry, + ) -> OptionsFlow: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} info: dict[str, str] = {} @@ -175,7 +180,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): existing_entry = await self.async_set_unique_id(isy_mac) if not existing_entry: return - if existing_entry.source == config_entries.SOURCE_IGNORE: + if existing_entry.source == SOURCE_IGNORE: raise AbortFlow("already_configured") parsed_url = urlparse(existing_entry.data[CONF_HOST]) if parsed_url.hostname != ip_address: @@ -202,7 +207,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) raise AbortFlow("already_configured") - async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Handle a discovered ISY/IoX device via dhcp.""" friendly_name = discovery_info.hostname if friendly_name.startswith("polisy") or friendly_name.startswith("eisy"): @@ -223,7 +230,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.context["title_placeholders"] = self.discovered_conf return await self.async_step_user() - 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 ISY/IoX Device.""" friendly_name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME] url = discovery_info.ssdp_location @@ -250,14 +259,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.context["title_placeholders"] = self.discovered_conf return await self.async_step_user() - 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.""" self._existing_entry = await self.async_set_unique_id(self.context["unique_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 reauth input.""" errors = {} assert self._existing_entry is not None @@ -299,16 +310,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Handle a option flow for ISY/IoX.""" - 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: return self.async_create_entry(title="", data=user_input) @@ -337,13 +348,13 @@ class OptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_form(step_id="init", data_schema=options_schema) -class InvalidHost(exceptions.HomeAssistantError): +class InvalidHost(HomeAssistantError): """Error to indicate the host value is invalid.""" -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/jellyfin/config_flow.py b/homeassistant/components/jellyfin/config_flow.py index 84360ed053e..b6702722006 100644 --- a/homeassistant/components/jellyfin/config_flow.py +++ b/homeassistant/components/jellyfin/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 ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.util.uuid import random_uuid_hex from .client_wrapper import CannotConnect, InvalidAuth, create_client, validate_input @@ -37,7 +36,7 @@ def _generate_client_device_id() -> str: return random_uuid_hex() -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class JellyfinConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Jellyfin.""" VERSION = 1 @@ -45,11 +44,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Initialize the Jellyfin config flow.""" self.client_device_id: str | None = None - self.entry: config_entries.ConfigEntry | None = None + self.entry: ConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a user defined configuration.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -92,14 +91,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="user", data_schema=STEP_USER_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: """Perform reauth upon an API authentication error.""" 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: """Dialog that informs the user that reauth is required.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/juicenet/config_flow.py b/homeassistant/components/juicenet/config_flow.py index 7fdc024df47..1385aa2eca8 100644 --- a/homeassistant/components/juicenet/config_flow.py +++ b/homeassistant/components/juicenet/config_flow.py @@ -1,11 +1,11 @@ """Config flow for JuiceNet integration.""" -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow from . import DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class JuiceNetConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for JuiceNet.""" VERSION = 1 diff --git a/homeassistant/components/justnimbus/config_flow.py b/homeassistant/components/justnimbus/config_flow.py index 536943ef607..08c02d40f94 100644 --- a/homeassistant/components/justnimbus/config_flow.py +++ b/homeassistant/components/justnimbus/config_flow.py @@ -8,9 +8,8 @@ from typing import Any import justnimbus import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_CLIENT_ID -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from .const import CONF_ZIP_CODE, DOMAIN @@ -25,15 +24,15 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class JustNimbusConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for JustNimbus.""" 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.""" if user_input is None: return self.async_show_form( @@ -76,7 +75,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors ) - async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, user_input: 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"] diff --git a/homeassistant/components/jvc_projector/config_flow.py b/homeassistant/components/jvc_projector/config_flow.py index 181d11e1f56..7564d571d3b 100644 --- a/homeassistant/components/jvc_projector/config_flow.py +++ b/homeassistant/components/jvc_projector/config_flow.py @@ -9,9 +9,8 @@ from jvcprojector import JvcProjector, JvcProjectorAuthError, JvcProjectorConnec from jvcprojector.projector import DEFAULT_PORT import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.device_registry import format_mac from homeassistant.util.network import is_host_valid @@ -27,7 +26,7 @@ class JvcProjectorConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user initiated device additions.""" errors = {} @@ -74,7 +73,9 @@ class JvcProjectorConfigFlow(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, user_input: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth on password authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -83,7 +84,7 @@ class JvcProjectorConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: Mapping[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Dialog that informs the user that reauth is required.""" assert self._reauth_entry diff --git a/homeassistant/components/kaleidescape/config_flow.py b/homeassistant/components/kaleidescape/config_flow.py index 5454f29f5cb..bb9f47ec1e8 100644 --- a/homeassistant/components/kaleidescape/config_flow.py +++ b/homeassistant/components/kaleidescape/config_flow.py @@ -2,21 +2,18 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, cast +from typing import Any, cast from urllib.parse import urlparse 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 from . import KaleidescapeDeviceInfo, UnsupportedError, validate_host from .const import DEFAULT_HOST, DOMAIN, NAME as KALEIDESCAPE_NAME -if TYPE_CHECKING: - from homeassistant.data_entry_flow import FlowResult - ERROR_CANNOT_CONNECT = "cannot_connect" ERROR_UNSUPPORTED = "unsupported" @@ -30,7 +27,7 @@ class KaleidescapeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user initiated device additions.""" errors = {} host = DEFAULT_HOST @@ -63,7 +60,9 @@ class KaleidescapeConfigFlow(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 discovered device.""" host = cast(str, urlparse(discovery_info.ssdp_location).hostname) serial_number = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL] @@ -93,7 +92,7 @@ class KaleidescapeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_discovery_confirm( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle addition of discovered device.""" if user_input is None: return self.async_show_form( diff --git a/homeassistant/components/keenetic_ndms2/config_flow.py b/homeassistant/components/keenetic_ndms2/config_flow.py index 535c83c927e..553204512e5 100644 --- a/homeassistant/components/keenetic_ndms2/config_flow.py +++ b/homeassistant/components/keenetic_ndms2/config_flow.py @@ -7,9 +7,13 @@ from urllib.parse import urlparse from ndms2_client import Client, ConnectionException, InterfaceInfo, TelnetConnection 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, + OptionsFlow, +) from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -18,7 +22,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 .const import ( @@ -37,7 +40,7 @@ from .const import ( from .router import KeeneticRouter -class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class KeeneticFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 @@ -52,7 +55,7 @@ class KeeneticFlowHandler(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: @@ -97,7 +100,9 @@ class KeeneticFlowHandler(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.""" friendly_name = discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "") @@ -124,7 +129,7 @@ class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return await self.async_step_user() -class KeeneticOptionsFlowHandler(config_entries.OptionsFlow): +class KeeneticOptionsFlowHandler(OptionsFlow): """Handle options.""" def __init__(self, config_entry: ConfigEntry) -> None: @@ -134,7 +139,7 @@ class KeeneticOptionsFlowHandler(config_entries.OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the options.""" router: KeeneticRouter = self.hass.data[DOMAIN][self.config_entry.entry_id][ ROUTER @@ -153,7 +158,7 @@ class KeeneticOptionsFlowHandler(config_entries.OptionsFlow): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the device tracker options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/kegtron/config_flow.py b/homeassistant/components/kegtron/config_flow.py index cc0457af87b..8e657de800d 100644 --- a/homeassistant/components/kegtron/config_flow.py +++ b/homeassistant/components/kegtron/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 KegtronConfigFlow(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 KegtronConfigFlow(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 KegtronConfigFlow(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/keymitt_ble/config_flow.py b/homeassistant/components/keymitt_ble/config_flow.py index 5665dc27d17..d0fb6ff0317 100644 --- a/homeassistant/components/keymitt_ble/config_flow.py +++ b/homeassistant/components/keymitt_ble/config_flow.py @@ -17,9 +17,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_ACCESS_TOKEN, CONF_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -54,7 +53,7 @@ class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the bluetooth discovery step.""" _LOGGER.debug("Discovered bluetooth device: %s", discovery_info) await self.async_set_unique_id(discovery_info.address) @@ -71,14 +70,14 @@ class MicroBotConfigFlow(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.""" # This is for backwards compatibility. return await self.async_step_init(user_input) async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Check if paired.""" errors: dict[str, str] = {} @@ -125,7 +124,7 @@ class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_link( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Given a configured host, will ask the user to press the button to pair.""" errors: dict[str, str] = {} token = randomid(32) diff --git a/homeassistant/components/kitchen_sink/config_flow.py b/homeassistant/components/kitchen_sink/config_flow.py index 54104784c50..56df82047ad 100644 --- a/homeassistant/components/kitchen_sink/config_flow.py +++ b/homeassistant/components/kitchen_sink/config_flow.py @@ -3,18 +3,17 @@ from __future__ import annotations from typing import Any -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from . import DOMAIN -class KitchenSinkConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class KitchenSinkConfigFlow(ConfigFlow, domain=DOMAIN): """Kitchen Sink configuration flow.""" VERSION = 1 - 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.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/kmtronic/config_flow.py b/homeassistant/components/kmtronic/config_flow.py index 8a00a03e673..e1d0bf95d09 100644 --- a/homeassistant/components/kmtronic/config_flow.py +++ b/homeassistant/components/kmtronic/config_flow.py @@ -8,9 +8,10 @@ from pykmtronic.auth import Auth from pykmtronic.hub import KMTronicHubAPI import voluptuous as vol -from homeassistant import config_entries, core, exceptions +from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import aiohttp_client from .const import CONF_REVERSE, DOMAIN @@ -26,7 +27,7 @@ DATA_SCHEMA = vol.Schema( ) -async def validate_input(hass: core.HomeAssistant, data): +async def validate_input(hass: HomeAssistant, data): """Validate the user input allows us to connect.""" session = aiohttp_client.async_get_clientsession(hass) auth = Auth( @@ -47,7 +48,7 @@ async def validate_input(hass: core.HomeAssistant, data): return data -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class KmtronicConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for kmtronic.""" VERSION = 1 @@ -55,7 +56,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> KMTronicOptionsFlow: """Get the options flow for this handler.""" return KMTronicOptionsFlow(config_entry) @@ -81,18 +82,18 @@ class ConfigFlow(config_entries.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.""" -class KMTronicOptionsFlow(config_entries.OptionsFlow): +class KMTronicOptionsFlow(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 diff --git a/homeassistant/components/knx/config_flow.py b/homeassistant/components/knx/config_flow.py index 5338a5fddca..e095f71f924 100644 --- a/homeassistant/components/knx/config_flow.py +++ b/homeassistant/components/knx/config_flow.py @@ -18,10 +18,15 @@ from xknx.io.self_description import request_description from xknx.io.util import validate_ip as xknx_validate_ip from xknx.secure.keyring import Keyring, XMLInterface -from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow +from homeassistant.config_entries import ( + ConfigEntry, + ConfigEntryBaseFlow, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowHandler, FlowResult from homeassistant.helpers import selector from homeassistant.helpers.typing import UNDEFINED @@ -96,7 +101,7 @@ _PORT_SELECTOR = vol.All( ) -class KNXCommonFlow(ABC, FlowHandler): +class KNXCommonFlow(ABC, ConfigEntryBaseFlow): """Base class for KNX flows.""" def __init__(self, initial_data: KNXConfigEntryData) -> None: @@ -115,7 +120,7 @@ class KNXCommonFlow(ABC, FlowHandler): self._async_scan_gen: AsyncGenerator[GatewayDescriptor, None] | None = None @abstractmethod - def finish_flow(self) -> FlowResult: + def finish_flow(self) -> ConfigFlowResult: """Finish the flow.""" @property @@ -136,7 +141,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_connection_type( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle connection type configuration.""" if user_input is not None: if self._async_scan_gen: @@ -202,7 +207,9 @@ class KNXCommonFlow(ABC, FlowHandler): step_id="connection_type", data_schema=vol.Schema(fields) ) - async def async_step_tunnel(self, user_input: dict | None = None) -> FlowResult: + async def async_step_tunnel( + self, user_input: dict | None = None + ) -> ConfigFlowResult: """Select a tunnel from a list. Will be skipped if the gateway scan was unsuccessful @@ -258,7 +265,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_manual_tunnel( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manually configure tunnel connection parameters. Fields default to preselected gateway if one was found.""" errors: dict = {} @@ -380,7 +387,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_secure_tunnel_manual( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Configure ip secure tunnelling manually.""" errors: dict = {} @@ -428,7 +435,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_secure_routing_manual( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Configure ip secure routing manually.""" errors: dict = {} @@ -481,7 +488,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_secure_knxkeys( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage upload of new KNX Keyring file.""" errors: dict[str, str] = {} @@ -533,7 +540,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_knxkeys_tunnel_select( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Select if a specific tunnel should be used from knxkeys file.""" errors = {} description_placeholders = {} @@ -618,7 +625,9 @@ class KNXCommonFlow(ABC, FlowHandler): description_placeholders=description_placeholders, ) - async def async_step_routing(self, user_input: dict | None = None) -> FlowResult: + async def async_step_routing( + self, user_input: dict | None = None + ) -> ConfigFlowResult: """Routing setup.""" errors: dict = {} _individual_address = ( @@ -703,7 +712,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_secure_key_source_menu_tunnel( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the key source menu.""" return self.async_show_menu( step_id="secure_key_source_menu_tunnel", @@ -712,7 +721,7 @@ class KNXCommonFlow(ABC, FlowHandler): async def async_step_secure_key_source_menu_routing( self, user_input: dict | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the key source menu.""" return self.async_show_menu( step_id="secure_key_source_menu_routing", @@ -736,7 +745,7 @@ class KNXConfigFlow(KNXCommonFlow, ConfigFlow, domain=DOMAIN): return KNXOptionsFlow(config_entry) @callback - def finish_flow(self) -> FlowResult: + def finish_flow(self) -> ConfigFlowResult: """Create the ConfigEntry.""" title = self.new_title or f"KNX {self.new_entry_data[CONF_KNX_CONNECTION_TYPE]}" return self.async_create_entry( @@ -744,7 +753,7 @@ class KNXConfigFlow(KNXCommonFlow, ConfigFlow, domain=DOMAIN): data=DEFAULT_ENTRY_DATA | self.new_entry_data, ) - 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 a flow initialized by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -762,7 +771,7 @@ class KNXOptionsFlow(KNXCommonFlow, OptionsFlow): super().__init__(initial_data=config_entry.data) # type: ignore[arg-type] @callback - def finish_flow(self) -> FlowResult: + def finish_flow(self) -> ConfigFlowResult: """Update the ConfigEntry and finish the flow.""" new_data = DEFAULT_ENTRY_DATA | self.initial_data | self.new_entry_data self.hass.config_entries.async_update_entry( @@ -774,7 +783,7 @@ class KNXOptionsFlow(KNXCommonFlow, OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage KNX options.""" return self.async_show_menu( step_id="init", @@ -787,7 +796,7 @@ class KNXOptionsFlow(KNXCommonFlow, OptionsFlow): async def async_step_communication_settings( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage KNX communication settings.""" if user_input is not None: self.new_entry_data = KNXConfigEntryData( diff --git a/homeassistant/components/kodi/config_flow.py b/homeassistant/components/kodi/config_flow.py index bd6d23e0f8e..74fc5e0cb09 100644 --- a/homeassistant/components/kodi/config_flow.py +++ b/homeassistant/components/kodi/config_flow.py @@ -6,8 +6,8 @@ import logging from pykodi import CannotConnectError, InvalidAuthError, Kodi, get_kodi_connection import voluptuous as vol -from homeassistant import config_entries, core, exceptions from homeassistant.components import zeroconf +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -17,8 +17,8 @@ from homeassistant.const import ( CONF_TIMEOUT, 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 homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import ( @@ -33,7 +33,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -async def validate_http(hass: core.HomeAssistant, data): +async def validate_http(hass: HomeAssistant, data): """Validate the user input allows us to connect over HTTP.""" host = data[CONF_HOST] @@ -56,7 +56,7 @@ async def validate_http(hass: core.HomeAssistant, data): raise InvalidAuth from error -async def validate_ws(hass: core.HomeAssistant, data): +async def validate_ws(hass: HomeAssistant, data): """Validate the user input allows us to connect over WS.""" if not (ws_port := data.get(CONF_WS_PORT)): return @@ -84,7 +84,7 @@ async def validate_ws(hass: core.HomeAssistant, data): raise WSCannotConnect from error -class KodiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class KodiConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Kodi.""" VERSION = 1 @@ -102,7 +102,7 @@ class KodiConfigFlow(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 self._port = discovery_info.port or DEFAULT_PORT @@ -313,13 +313,13 @@ class KodiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return data -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 WSCannotConnect(exceptions.HomeAssistantError): +class WSCannotConnect(HomeAssistantError): """Error to indicate we cannot connect to websocket.""" diff --git a/homeassistant/components/konnected/config_flow.py b/homeassistant/components/konnected/config_flow.py index c9889dd6464..f6225760feb 100644 --- a/homeassistant/components/konnected/config_flow.py +++ b/homeassistant/components/konnected/config_flow.py @@ -11,12 +11,17 @@ from urllib.parse import urlparse import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import ssdp from homeassistant.components.binary_sensor import ( DEVICE_CLASSES_SCHEMA, BinarySensorDeviceClass, ) +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import ( CONF_ACCESS_TOKEN, CONF_BINARY_SENSORS, @@ -33,7 +38,6 @@ from homeassistant.const import ( CONF_ZONE, ) from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from .const import ( @@ -166,7 +170,7 @@ CONFIG_ENTRY_SCHEMA = vol.Schema( ) -class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class KonnectedFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for Konnected Panels.""" VERSION = 1 @@ -244,7 +248,9 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) return await self.async_step_user() - 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 konnected panel. This flow is triggered by the SSDP component. It will check if the @@ -376,16 +382,16 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Return the Options Flow.""" return OptionsFlowHandler(config_entry) -class OptionsFlowHandler(config_entries.OptionsFlow): +class OptionsFlowHandler(OptionsFlow): """Handle a option flow for a Konnected Panel.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.entry = config_entry self.model = self.entry.data[CONF_MODEL] diff --git a/homeassistant/components/kostal_plenticore/config_flow.py b/homeassistant/components/kostal_plenticore/config_flow.py index 8dd3a823570..c88006e59b6 100644 --- a/homeassistant/components/kostal_plenticore/config_flow.py +++ b/homeassistant/components/kostal_plenticore/config_flow.py @@ -5,7 +5,7 @@ from aiohttp.client_exceptions import ClientError from pykoplenti import ApiClient, AuthenticationException import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow from homeassistant.const import CONF_BASE, CONF_HOST, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -38,7 +38,7 @@ async def test_connection(hass: HomeAssistant, data) -> str: return values["scb:network"][hostname_id] -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class KostalPlenticoreConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Kostal Plenticore Solar Inverter.""" VERSION = 1 diff --git a/homeassistant/components/kraken/config_flow.py b/homeassistant/components/kraken/config_flow.py index ff4c882504c..fba08b63071 100644 --- a/homeassistant/components/kraken/config_flow.py +++ b/homeassistant/components/kraken/config_flow.py @@ -7,17 +7,21 @@ import krakenex from pykrakenapi.pykrakenapi import KrakenAPI import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_SCAN_INTERVAL from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from .const import CONF_TRACKED_ASSET_PAIRS, DEFAULT_SCAN_INTERVAL, DOMAIN from .utils import get_tradable_asset_pairs -class KrakenConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class KrakenConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for kraken.""" VERSION = 1 @@ -25,14 +29,14 @@ class KrakenConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> KrakenOptionsFlowHandler: """Get the options flow for this handler.""" return KrakenOptionsFlowHandler(config_entry) 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="already_configured") @@ -45,16 +49,16 @@ class KrakenConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -class KrakenOptionsFlowHandler(config_entries.OptionsFlow): +class KrakenOptionsFlowHandler(OptionsFlow): """Handle Kraken client options.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize Kraken options flow.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the Kraken options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/lacrosse_view/config_flow.py b/homeassistant/components/lacrosse_view/config_flow.py index 67d294de179..db6def15835 100644 --- a/homeassistant/components/lacrosse_view/config_flow.py +++ b/homeassistant/components/lacrosse_view/config_flow.py @@ -8,9 +8,8 @@ from typing import Any from lacrosse_view import LaCrosse, Location, LoginError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult 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 @@ -45,7 +44,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> list[Loca return locations -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LaCrosseViewConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for LaCrosse View.""" VERSION = 1 @@ -54,11 +53,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Initialize the config flow.""" self.data: dict[str, str] = {} self.locations: list[Location] = [] - self._reauth_entry: config_entries.ConfigEntry | None = None + self._reauth_entry: ConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" if user_input is None: _LOGGER.debug("Showing initial form") @@ -100,7 +99,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_location( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the location step.""" if not user_input: @@ -135,7 +134,9 @@ class ConfigFlow(config_entries.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: """Reauth in case of a password change or other error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/lamarzocco/config_flow.py b/homeassistant/components/lamarzocco/config_flow.py index 7c63532104f..d9fa21c5419 100644 --- a/homeassistant/components/lamarzocco/config_flow.py +++ b/homeassistant/components/lamarzocco/config_flow.py @@ -7,9 +7,8 @@ from lmcloud import LMCloud as LaMarzoccoClient from lmcloud.exceptions import AuthFail, RequestNotSuccessful import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from homeassistant.helpers.selector import ( SelectOptionDict, @@ -35,7 +34,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} @@ -89,7 +88,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_machine_selection( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Let user select machine to connect to.""" errors: dict[str, str] = {} if user_input: @@ -141,7 +140,9 @@ class LmConfigFlow(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 an API authentication error.""" self.reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -150,7 +151,7 @@ class LmConfigFlow(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.""" if not user_input: return self.async_show_form( diff --git a/homeassistant/components/lametric/config_flow.py b/homeassistant/components/lametric/config_flow.py index 1dad190d706..0fdd566fada 100644 --- a/homeassistant/components/lametric/config_flow.py +++ b/homeassistant/components/lametric/config_flow.py @@ -28,9 +28,9 @@ from homeassistant.components.ssdp import ( ATTR_UPNP_SERIAL, SsdpServiceInfo, ) -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_DEVICE, CONF_HOST, CONF_MAC -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler from homeassistant.helpers.device_registry import format_mac @@ -72,11 +72,13 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initiated by the user.""" return await self.async_step_choice_enter_manual_or_fetch_cloud() - async def async_step_ssdp(self, discovery_info: SsdpServiceInfo) -> FlowResult: + async def async_step_ssdp( + self, discovery_info: SsdpServiceInfo + ) -> ConfigFlowResult: """Handle a flow initiated by SSDP discovery.""" url = URL(discovery_info.ssdp_location or "") if url.host is None or not ( @@ -106,7 +108,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): self.discovered_serial = serial return await self.async_step_choice_enter_manual_or_fetch_cloud() - 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 LaMetric.""" self.reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -115,7 +119,7 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): async def async_step_choice_enter_manual_or_fetch_cloud( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user's choice. Either enter the manual credentials or fetch the cloud credentials. @@ -127,7 +131,7 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): async def async_step_manual_entry( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the user's choice of entering the device manually.""" errors: dict[str, str] = {} if user_input is not None: @@ -166,7 +170,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): errors=errors, ) - async def async_step_cloud_fetch_devices(self, data: dict[str, Any]) -> FlowResult: + async def async_step_cloud_fetch_devices( + self, data: dict[str, Any] + ) -> ConfigFlowResult: """Fetch information about devices from the cloud.""" lametric = LaMetricCloud( token=data["token"]["access_token"], @@ -184,7 +190,7 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): async def async_step_cloud_select_device( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle device selection from devices offered by the cloud.""" if self.discovered: user_input = {CONF_DEVICE: self.discovered_serial} @@ -232,7 +238,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): errors=errors, ) - async def _async_step_create_entry(self, host: str, api_key: str) -> FlowResult: + async def _async_step_create_entry( + self, host: str, api_key: str + ) -> ConfigFlowResult: """Create entry.""" lametric = LaMetricDevice( host=host, @@ -287,7 +295,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): }, ) - async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: DhcpServiceInfo + ) -> ConfigFlowResult: """Handle dhcp discovery to update existing entries.""" mac = format_mac(discovery_info.macaddress) for entry in self._async_current_entries(): diff --git a/homeassistant/components/landisgyr_heat_meter/config_flow.py b/homeassistant/components/landisgyr_heat_meter/config_flow.py index 479e7107025..64f4555c8fb 100644 --- a/homeassistant/components/landisgyr_heat_meter/config_flow.py +++ b/homeassistant/components/landisgyr_heat_meter/config_flow.py @@ -10,11 +10,10 @@ from serial.tools import list_ports import ultraheat_api import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import usb +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from .const import DOMAIN, ULTRAHEAT_TIMEOUT @@ -30,14 +29,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LandisgyrConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Ultraheat Heat Meter.""" VERSION = 2 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step when setting up serial configuration.""" errors = {} @@ -63,7 +62,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_setup_serial_manual_path( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Set path manually.""" errors = {} diff --git a/homeassistant/components/lastfm/config_flow.py b/homeassistant/components/lastfm/config_flow.py index 4ff809b56d0..51791de54fb 100644 --- a/homeassistant/components/lastfm/config_flow.py +++ b/homeassistant/components/lastfm/config_flow.py @@ -9,11 +9,11 @@ import voluptuous as vol from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, + ConfigFlowResult, OptionsFlowWithConfigEntry, ) from homeassistant.const import CONF_API_KEY from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.selector import ( SelectOptionDict, SelectSelector, @@ -83,7 +83,7 @@ class LastFmConfigFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Initialize user input.""" errors: dict[str, str] = {} if user_input is not None: @@ -102,7 +102,7 @@ class LastFmConfigFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_friends( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Form to select other users and friends.""" errors: dict[str, str] = {} if user_input is not None: @@ -159,7 +159,7 @@ class LastFmOptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Initialize form.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/launch_library/config_flow.py b/homeassistant/components/launch_library/config_flow.py index d57bc3b7d01..3349efb9c28 100644 --- a/homeassistant/components/launch_library/config_flow.py +++ b/homeassistant/components/launch_library/config_flow.py @@ -3,20 +3,19 @@ from __future__ import annotations 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 LaunchLibraryFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class LaunchLibraryFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Launch Library component.""" VERSION = 1 async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by the user.""" # Check if already configured if self._async_current_entries(): diff --git a/homeassistant/components/laundrify/config_flow.py b/homeassistant/components/laundrify/config_flow.py index 55a29fec2e7..e11ef88f2df 100644 --- a/homeassistant/components/laundrify/config_flow.py +++ b/homeassistant/components/laundrify/config_flow.py @@ -13,9 +13,8 @@ from laundrify_aio.exceptions import ( ) from voluptuous import Required, Schema -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CODE -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -32,13 +31,13 @@ class LaundrifyConfigFlow(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_init(user_input) async def async_step_init( 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="init", data_schema=CONFIG_SCHEMA) @@ -77,13 +76,15 @@ class LaundrifyConfigFlow(ConfigFlow, domain=DOMAIN): step_id="init", data_schema=CONFIG_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: """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( diff --git a/homeassistant/components/lcn/config_flow.py b/homeassistant/components/lcn/config_flow.py index 09f588b6953..87dc9c2b602 100644 --- a/homeassistant/components/lcn/config_flow.py +++ b/homeassistant/components/lcn/config_flow.py @@ -5,7 +5,12 @@ import logging import pypck -from homeassistant import config_entries +from homeassistant.config_entries import ( + SOURCE_IMPORT, + ConfigEntry, + ConfigFlow, + ConfigFlowResult, +) from homeassistant.const import ( CONF_HOST, CONF_IP_ADDRESS, @@ -14,7 +19,6 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.typing import ConfigType from .const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN @@ -23,9 +27,7 @@ from .helpers import purge_device_registry, purge_entity_registry _LOGGER = logging.getLogger(__name__) -def get_config_entry( - hass: HomeAssistant, data: ConfigType -) -> config_entries.ConfigEntry | None: +def get_config_entry(hass: HomeAssistant, data: ConfigType) -> ConfigEntry | None: """Check config entries for already configured entries based on the ip address/port.""" return next( ( @@ -65,12 +67,12 @@ async def validate_connection(host_name: str, data: ConfigType) -> ConfigType: return data -class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class LcnFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a LCN config flow.""" VERSION = 1 - async def async_step_import(self, data: ConfigType) -> FlowResult: + async def async_step_import(self, data: ConfigType) -> ConfigFlowResult: """Import existing configuration from LCN.""" host_name = data[CONF_HOST] # validate the imported connection parameters @@ -94,7 +96,7 @@ class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): # check if we already have a host with the same address configured if entry := get_config_entry(self.hass, data): - entry.source = config_entries.SOURCE_IMPORT + entry.source = SOURCE_IMPORT # Cleanup entity and device registry, if we imported from configuration.yaml to # remove orphans when entities were removed from configuration purge_entity_registry(self.hass, entry.entry_id, data) diff --git a/homeassistant/components/ld2410_ble/config_flow.py b/homeassistant/components/ld2410_ble/config_flow.py index d56610f87a8..b0286b299a3 100644 --- a/homeassistant/components/ld2410_ble/config_flow.py +++ b/homeassistant/components/ld2410_ble/config_flow.py @@ -8,20 +8,19 @@ from bluetooth_data_tools import human_readable_name from ld2410_ble import BLEAK_EXCEPTIONS, LD2410BLE 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 FlowResult from .const import DOMAIN, LOCAL_NAMES _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class Ld2410BleConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for LD2410 BLE.""" VERSION = 1 @@ -33,7 +32,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() @@ -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 user step to pick discovered device.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/leaone/config_flow.py b/homeassistant/components/leaone/config_flow.py index 5bbf2917332..fba9f103446 100644 --- a/homeassistant/components/leaone/config_flow.py +++ b/homeassistant/components/leaone/config_flow.py @@ -7,9 +7,8 @@ from leaone_ble import LeaoneBluetoothDeviceData as DeviceData import voluptuous as vol from homeassistant.components.bluetooth import 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 @@ -25,7 +24,7 @@ class LeaoneConfigFlow(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/led_ble/config_flow.py b/homeassistant/components/led_ble/config_flow.py index 44436180ea8..70b4f78e840 100644 --- a/homeassistant/components/led_ble/config_flow.py +++ b/homeassistant/components/led_ble/config_flow.py @@ -8,20 +8,19 @@ from bluetooth_data_tools import human_readable_name from led_ble import BLEAK_EXCEPTIONS, LEDBLE 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 FlowResult from .const import DOMAIN, LOCAL_NAMES, UNSUPPORTED_SUB_MODEL _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LedBleConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Yale Access Bluetooth.""" VERSION = 1 @@ -33,7 +32,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the bluetooth discovery step.""" if discovery_info.name.startswith(UNSUPPORTED_SUB_MODEL): # These versions speak a different protocol @@ -51,7 +50,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] = {} diff --git a/homeassistant/components/lg_soundbar/config_flow.py b/homeassistant/components/lg_soundbar/config_flow.py index fde5c20ebd7..c28c3e458af 100644 --- a/homeassistant/components/lg_soundbar/config_flow.py +++ b/homeassistant/components/lg_soundbar/config_flow.py @@ -5,9 +5,8 @@ from queue import Empty, Full, Queue import temescal 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 .const import DEFAULT_PORT, DOMAIN @@ -67,12 +66,12 @@ def test_connect(host, port): return details -class LGSoundbarConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LGSoundbarConfigFlow(ConfigFlow, domain=DOMAIN): """LG Soundbar config flow.""" VERSION = 1 - async def async_step_user(self, user_input=None) -> FlowResult: + async def async_step_user(self, user_input=None) -> ConfigFlowResult: """Handle a flow initiated by the user.""" if user_input is None: return self._show_form() diff --git a/homeassistant/components/lidarr/config_flow.py b/homeassistant/components/lidarr/config_flow.py index a0b73950766..b1b04f6e778 100644 --- a/homeassistant/components/lidarr/config_flow.py +++ b/homeassistant/components/lidarr/config_flow.py @@ -9,10 +9,9 @@ from aiopyarr import exceptions from aiopyarr.lidarr_client import LidarrClient import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL 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, DOMAIN @@ -27,7 +26,9 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN): """Initialize the flow.""" self.entry: ConfigEntry | None = None - async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, user_input: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) @@ -35,7 +36,7 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm reauth dialog.""" if user_input is not None: return await self.async_step_user() @@ -45,7 +46,7 @@ class LidarrConfigFlow(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 = {} diff --git a/homeassistant/components/lifx/config_flow.py b/homeassistant/components/lifx/config_flow.py index b6fd67c0356..dc0a0ab2d36 100644 --- a/homeassistant/components/lifx/config_flow.py +++ b/homeassistant/components/lifx/config_flow.py @@ -8,12 +8,11 @@ from aiolifx.aiolifx import Light from aiolifx.connection import LIFXConnection import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf from homeassistant.components.dhcp import DhcpServiceInfo +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE, CONF_HOST from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import device_registry as dr from homeassistant.helpers.typing import DiscoveryInfoType @@ -36,7 +35,7 @@ from .util import ( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LifXConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for LIFX.""" VERSION = 1 @@ -46,7 +45,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._discovered_devices: dict[str, Light] = {} self._discovered_device: Light | None = None - async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: DhcpServiceInfo + ) -> ConfigFlowResult: """Handle discovery via DHCP.""" mac = discovery_info.macaddress host = discovery_info.ip @@ -69,13 +70,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_homekit( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle HomeKit discovery.""" return await self._async_handle_discovery(host=discovery_info.host) async def async_step_integration_discovery( self, discovery_info: DiscoveryInfoType - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle LIFX UDP broadcast discovery.""" serial = discovery_info[CONF_SERIAL] host = discovery_info[CONF_HOST] @@ -85,7 +86,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def _async_handle_discovery( self, host: str, serial: str | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle any discovery.""" self._async_abort_entries_match({CONF_HOST: host}) self.context[CONF_HOST] = host @@ -120,7 +121,7 @@ class ConfigFlow(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._discovered_device is not None discovered = self._discovered_device @@ -146,7 +147,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: @@ -168,7 +169,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_pick_device( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the step to pick discovered device.""" if user_input is not None: serial = user_input[CONF_DEVICE] @@ -207,7 +208,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) @callback - def _async_create_entry_from_device(self, device: Light) -> FlowResult: + def _async_create_entry_from_device(self, device: Light) -> ConfigFlowResult: """Create a config entry from a smart device.""" self._abort_if_unique_id_configured(updates={CONF_HOST: device.ip_addr}) return self.async_create_entry( diff --git a/homeassistant/components/linear_garage_door/config_flow.py b/homeassistant/components/linear_garage_door/config_flow.py index 6bca49adb4c..c8892a8f99c 100644 --- a/homeassistant/components/linear_garage_door/config_flow.py +++ b/homeassistant/components/linear_garage_door/config_flow.py @@ -10,10 +10,9 @@ from linear_garage_door import Linear from linear_garage_door.errors import InvalidLoginError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_EMAIL, CONF_PASSWORD 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 @@ -63,7 +62,7 @@ async def validate_input( return info -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Linear Garage Door.""" VERSION = 1 @@ -71,11 +70,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Initialize the config flow.""" self.data: dict[str, Sequence[Collection[str]]] = {} - self._reauth_entry: config_entries.ConfigEntry | None = None + self._reauth_entry: ConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" data_schema = STEP_USER_DATA_SCHEMA @@ -115,7 +114,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_site( self, user_input: dict[str, Any] | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the site step.""" if isinstance(self.data["sites"], list): @@ -150,7 +149,9 @@ class ConfigFlow(config_entries.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: """Reauth in case of a password change or other error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/litejet/config_flow.py b/homeassistant/components/litejet/config_flow.py index a7b5a6f000e..3c452f7b4d7 100644 --- a/homeassistant/components/litejet/config_flow.py +++ b/homeassistant/components/litejet/config_flow.py @@ -7,25 +7,29 @@ import pylitejet from serial import SerialException import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_PORT from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import CONF_DEFAULT_TRANSITION, DOMAIN -class LiteJetOptionsFlow(config_entries.OptionsFlow): +class LiteJetOptionsFlow(OptionsFlow): """Handle LiteJet options.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize LiteJet options flow.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage LiteJet options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) @@ -45,12 +49,12 @@ class LiteJetOptionsFlow(config_entries.OptionsFlow): ) -class LiteJetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LiteJetConfigFlow(ConfigFlow, domain=DOMAIN): """LiteJet config flow.""" async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Create a LiteJet config entry based upon user input.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -79,7 +83,7 @@ class LiteJetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> LiteJetOptionsFlow: """Get the options flow for this handler.""" return LiteJetOptionsFlow(config_entry) diff --git a/homeassistant/components/litterrobot/config_flow.py b/homeassistant/components/litterrobot/config_flow.py index 558945ca1db..54377d43980 100644 --- a/homeassistant/components/litterrobot/config_flow.py +++ b/homeassistant/components/litterrobot/config_flow.py @@ -9,9 +9,8 @@ from pylitterbot import Account from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginException 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 DOMAIN @@ -23,21 +22,23 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LitterRobotConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Litter-Robot.""" VERSION = 1 username: 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: """Handle a reauthorization flow request.""" self.username = entry_data[CONF_USERNAME] return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle user's reauth credentials.""" errors = {} if user_input: @@ -62,7 +63,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: Mapping[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" errors = {} diff --git a/homeassistant/components/livisi/config_flow.py b/homeassistant/components/livisi/config_flow.py index c8685eb2390..1b5c4892eee 100644 --- a/homeassistant/components/livisi/config_flow.py +++ b/homeassistant/components/livisi/config_flow.py @@ -8,15 +8,14 @@ from aiohttp import ClientConnectorError from aiolivisi import AioLivisi, errors as livisi_errors import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from .const import DOMAIN, LOGGER -class LivisiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class LivisiFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Livisi Smart Home config flow.""" def __init__(self) -> None: @@ -31,7 +30,7 @@ class LivisiFlowHandler(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 user_input is None: return self.async_show_form(step_id="user", data_schema=self.data_schema) @@ -70,7 +69,7 @@ class LivisiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def create_entity( self, user_input: dict[str, str], controller_info: dict[str, Any] - ) -> FlowResult: + ) -> ConfigFlowResult: """Create LIVISI entity.""" if (controller_data := controller_info.get("gateway")) is None: controller_data = controller_info diff --git a/homeassistant/components/local_calendar/config_flow.py b/homeassistant/components/local_calendar/config_flow.py index a5a75fee58b..8703def7304 100644 --- a/homeassistant/components/local_calendar/config_flow.py +++ b/homeassistant/components/local_calendar/config_flow.py @@ -5,8 +5,7 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.util import slugify from .const import CONF_CALENDAR_NAME, CONF_STORAGE_KEY, DOMAIN @@ -18,14 +17,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LocalCalendarConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Local Calendar.""" 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/local_ip/config_flow.py b/homeassistant/components/local_ip/config_flow.py index be708f5d8b9..09e9835e65e 100644 --- a/homeassistant/components/local_ip/config_flow.py +++ b/homeassistant/components/local_ip/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 @@ -14,7 +13,7 @@ class SimpleConfigFlow(ConfigFlow, domain=DOMAIN): 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/local_todo/config_flow.py b/homeassistant/components/local_todo/config_flow.py index 73328358a3c..dc596c91d9c 100644 --- a/homeassistant/components/local_todo/config_flow.py +++ b/homeassistant/components/local_todo/config_flow.py @@ -6,8 +6,7 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.util import slugify from .const import CONF_STORAGE_KEY, CONF_TODO_LIST_NAME, DOMAIN @@ -21,14 +20,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LocalTodoConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Local To-do.""" 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/logi_circle/config_flow.py b/homeassistant/components/logi_circle/config_flow.py index be22a9a5d30..6b7d6881c19 100644 --- a/homeassistant/components/logi_circle/config_flow.py +++ b/homeassistant/components/logi_circle/config_flow.py @@ -7,8 +7,8 @@ from logi_circle import LogiCircle from logi_circle.exception import AuthorizationFailed import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.http import HomeAssistantView +from homeassistant.config_entries import ConfigFlow from homeassistant.const import ( CONF_API_KEY, CONF_CLIENT_ID, @@ -53,7 +53,7 @@ def register_flow_implementation( } -class LogiCircleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class LogiCircleFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Logi Circle component.""" VERSION = 1 diff --git a/homeassistant/components/lookin/config_flow.py b/homeassistant/components/lookin/config_flow.py index 895d071ab4e..27ba96e9eb0 100644 --- a/homeassistant/components/lookin/config_flow.py +++ b/homeassistant/components/lookin/config_flow.py @@ -8,10 +8,9 @@ import aiohttp from aiolookin import Device, LookInHttpProtocol, NoUsableService 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 -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -19,7 +18,7 @@ from .const import DOMAIN LOGGER = logging.getLogger(__name__) -class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class LookinFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for lookin.""" def __init__(self) -> None: @@ -29,7 +28,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Start a discovery flow from zeroconf.""" uid: str = discovery_info.hostname.removesuffix(".local.") host: str = discovery_info.host @@ -52,7 +51,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """User initiated discover flow.""" errors: dict[str, str] = {} @@ -88,7 +87,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_discovery_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm the discover flow.""" assert self._host is not None if user_input is None: diff --git a/homeassistant/components/loqed/config_flow.py b/homeassistant/components/loqed/config_flow.py index 1c76f480529..a0f23b4359d 100644 --- a/homeassistant/components/loqed/config_flow.py +++ b/homeassistant/components/loqed/config_flow.py @@ -9,12 +9,11 @@ import aiohttp from loqedAPI import cloud_loqed, loqed import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import webhook from homeassistant.components.zeroconf import ZeroconfServiceInfo +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_TOKEN, CONF_NAME, CONF_WEBHOOK_ID 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 @@ -23,7 +22,7 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class LoqedConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Loqed.""" VERSION = 1 @@ -83,7 +82,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.host self._host = host @@ -101,7 +100,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show userform to user.""" user_data_schema = ( vol.Schema( diff --git a/homeassistant/components/luftdaten/config_flow.py b/homeassistant/components/luftdaten/config_flow.py index 0fa800f1d8b..f2f8a9366cd 100644 --- a/homeassistant/components/luftdaten/config_flow.py +++ b/homeassistant/components/luftdaten/config_flow.py @@ -7,22 +7,21 @@ from luftdaten import Luftdaten from luftdaten.exceptions import LuftdatenConnectionError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_SHOW_ON_MAP from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import CONF_SENSOR_ID, DOMAIN -class SensorCommunityFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class SensorCommunityFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Sensor.Community config flow.""" VERSION = 1 @callback - def _show_form(self, errors: dict[str, str] | None = None) -> FlowResult: + 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", @@ -37,7 +36,7 @@ class SensorCommunityFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the start of the config flow.""" if user_input is None: return self._show_form() diff --git a/homeassistant/components/lupusec/config_flow.py b/homeassistant/components/lupusec/config_flow.py index 1fae687cbdb..4129c33eabf 100644 --- a/homeassistant/components/lupusec/config_flow.py +++ b/homeassistant/components/lupusec/config_flow.py @@ -16,7 +16,6 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from .const import DOMAIN @@ -37,7 +36,7 @@ class LupusecConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> config_entries.ConfigFlowResult: """Handle a flow initiated by the user.""" errors = {} @@ -67,7 +66,9 @@ class LupusecConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult: + async def async_step_import( + self, user_input: dict[str, Any] + ) -> config_entries.ConfigFlowResult: """Import the yaml config.""" self._async_abort_entries_match( { diff --git a/homeassistant/components/lutron/config_flow.py b/homeassistant/components/lutron/config_flow.py index 04628849230..1a21ab37469 100644 --- a/homeassistant/components/lutron/config_flow.py +++ b/homeassistant/components/lutron/config_flow.py @@ -8,9 +8,8 @@ from urllib.error import HTTPError from pylutron import Lutron 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_USERNAME -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -24,7 +23,7 @@ class LutronConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """First step in the config flow.""" # Check if a configuration entry already exists @@ -74,7 +73,9 @@ class LutronConfigFlow(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult: + async def async_step_import( + self, import_config: dict[str, Any] + ) -> ConfigFlowResult: """Attempt to import the existing configuration.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/lutron_caseta/config_flow.py b/homeassistant/components/lutron_caseta/config_flow.py index 21f7cbd9683..7323acc3e4c 100644 --- a/homeassistant/components/lutron_caseta/config_flow.py +++ b/homeassistant/components/lutron_caseta/config_flow.py @@ -10,11 +10,10 @@ from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY, async_pair from pylutron_caseta.smartbridge import Smartbridge 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_NAME from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import ( ABORT_REASON_CANNOT_CONNECT, @@ -45,7 +44,7 @@ DATA_SCHEMA_USER = vol.Schema({vol.Required(CONF_HOST): str}) TLS_ASSET_TEMPLATE = "lutron_caseta-{}-{}.pem" -class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class LutronCasetaFlowHandler(ConfigFlow, domain=DOMAIN): """Handle Lutron Caseta config flow.""" VERSION = 1 @@ -67,7 +66,7 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" hostname = discovery_info.hostname if hostname is None or not hostname.lower().startswith("lutron-"): @@ -88,7 +87,7 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_homekit( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by homekit discovery.""" return await self.async_step_zeroconf(discovery_info) diff --git a/homeassistant/components/lyric/config_flow.py b/homeassistant/components/lyric/config_flow.py index de6808dd0de..16c5c40cbea 100644 --- a/homeassistant/components/lyric/config_flow.py +++ b/homeassistant/components/lyric/config_flow.py @@ -5,7 +5,7 @@ from collections.abc import Mapping import logging from typing import Any -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlowResult from homeassistant.helpers import config_entry_oauth2_flow from .const import DOMAIN @@ -23,19 +23,21 @@ class OAuth2FlowHandler( """Return logger.""" return logging.getLogger(__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: """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(step_id="reauth_confirm") return await self.async_step_user() - async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult: + async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult: """Create an oauth config entry or update existing entry for reauth.""" existing_entry = await self.async_set_unique_id(DOMAIN) if existing_entry: diff --git a/homeassistant/components/matter/config_flow.py b/homeassistant/components/matter/config_flow.py index 1636790c4cb..8982067207e 100644 --- a/homeassistant/components/matter/config_flow.py +++ b/homeassistant/components/matter/config_flow.py @@ -8,7 +8,6 @@ from matter_server.client import MatterClient from matter_server.client.exceptions import CannotConnect, InvalidServerVersion import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.hassio import ( AddonError, AddonInfo, @@ -17,9 +16,10 @@ from homeassistant.components.hassio import ( HassioServiceInfo, is_hassio, ) +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_URL from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import aiohttp_client @@ -56,7 +56,7 @@ def build_ws_address(host: str, port: int) -> str: return f"ws://{host}:{port}/ws" -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MatterConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Matter.""" VERSION = 1 @@ -72,7 +72,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_install_addon( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Install Matter Server add-on.""" if not self.install_task: self.install_task = self.hass.async_create_task(self._async_install_addon()) @@ -98,7 +98,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_install_failed( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Add-on installation failed.""" return self.async_abort(reason="addon_install_failed") @@ -120,7 +120,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_start_addon( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Start Matter Server add-on.""" if not self.start_task: self.start_task = self.hass.async_create_task(self._async_start_addon()) @@ -143,7 +143,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_start_failed( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Add-on start failed.""" return self.async_abort(reason="addon_start_failed") @@ -186,7 +186,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 is_hassio(self.hass): return await self.async_step_on_supervisor() @@ -195,7 +195,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_manual( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a manual configuration.""" if user_input is None: return self.async_show_form( @@ -222,7 +222,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="manual", data_schema=get_manual_schema(user_input), errors=errors ) - async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult: + async def async_step_hassio( + self, discovery_info: HassioServiceInfo + ) -> ConfigFlowResult: """Receive configuration from add-on discovery info. This flow is triggered by the Matter Server add-on. @@ -240,7 +242,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_hassio_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm the add-on discovery.""" if user_input is not None: return await self.async_step_on_supervisor( @@ -251,7 +253,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_on_supervisor( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle logic when on Supervisor host.""" if user_input is None: return self.async_show_form( @@ -274,7 +276,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_finish_addon_setup( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Prepare info needed to complete the config entry.""" if not self.ws_address: discovery_info = await self._async_get_addon_discovery_info() @@ -289,7 +291,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self._async_create_entry_or_abort() - async def _async_create_entry_or_abort(self) -> FlowResult: + async def _async_create_entry_or_abort(self) -> ConfigFlowResult: """Return a config entry for the flow or abort if already configured.""" assert self.ws_address is not None diff --git a/homeassistant/components/meater/config_flow.py b/homeassistant/components/meater/config_flow.py index 91a927a5fb2..d325bcd4e5a 100644 --- a/homeassistant/components/meater/config_flow.py +++ b/homeassistant/components/meater/config_flow.py @@ -7,9 +7,8 @@ from typing import Any from meater import AuthenticationError, MeaterApi, ServiceUnavailableError 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 import aiohttp_client from .const import DOMAIN @@ -20,7 +19,7 @@ USER_SCHEMA = vol.Schema( ) -class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MeaterConfigFlow(ConfigFlow, domain=DOMAIN): """Meater Config Flow.""" _data_schema = USER_SCHEMA @@ -28,7 +27,7 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Define the login user step.""" if user_input is None: return self.async_show_form( @@ -45,7 +44,9 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return await self._try_connect_meater("user", None, username, password) - 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._data_schema = REAUTH_SCHEMA self._username = entry_data[CONF_USERNAME] @@ -53,7 +54,7 @@ class MeaterConfigFlow(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.""" placeholders = {"username": self._username} if not user_input: @@ -70,7 +71,7 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def _try_connect_meater( self, step_id, placeholders: dict[str, str] | None, username: str, password: str - ) -> FlowResult: + ) -> ConfigFlowResult: session = aiohttp_client.async_get_clientsession(self.hass) api = MeaterApi(session) diff --git a/homeassistant/components/medcom_ble/config_flow.py b/homeassistant/components/medcom_ble/config_flow.py index 30a87afbb72..faf482ca1f9 100644 --- a/homeassistant/components/medcom_ble/config_flow.py +++ b/homeassistant/components/medcom_ble/config_flow.py @@ -16,9 +16,9 @@ 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 AbortFlow, FlowResult +from homeassistant.data_entry_flow import AbortFlow from .const import DOMAIN @@ -51,7 +51,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the bluetooth discovery step.""" _LOGGER.debug("Discovered BLE device: %s", discovery_info.name) await self.async_set_unique_id(discovery_info.address) @@ -67,7 +67,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_bluetooth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm discovery.""" # We always will have self._discovery_info be a BluetoothServiceInfo at this point # and this helps mypy not complain @@ -84,7 +84,7 @@ class InspectorBLEConfigFlow(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] @@ -123,7 +123,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN): ), ) - async def async_step_check_connection(self) -> FlowResult: + async def async_step_check_connection(self) -> ConfigFlowResult: """Check we can connect to the device before considering the configuration is successful.""" # We always will have self._discovery_info be a BluetoothServiceInfo at this point # and this helps mypy not complain diff --git a/homeassistant/components/melcloud/config_flow.py b/homeassistant/components/melcloud/config_flow.py index 88f658a0615..f848846409d 100644 --- a/homeassistant/components/melcloud/config_flow.py +++ b/homeassistant/components/melcloud/config_flow.py @@ -11,9 +11,8 @@ from aiohttp import ClientError, ClientResponseError import pymelcloud import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -21,14 +20,14 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class FlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 - entry: config_entries.ConfigEntry | None = None + entry: ConfigEntry | None = None - async def _create_entry(self, username: str, token: str) -> FlowResult: + async def _create_entry(self, username: str, token: str) -> ConfigFlowResult: """Register new entry.""" await self.async_set_unique_id(username) self._abort_if_unique_id_configured({CONF_TOKEN: token}) @@ -42,7 +41,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): *, password: str | None = None, token: str | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Create client.""" try: async with asyncio.timeout(10): @@ -67,7 +66,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( @@ -79,14 +78,16 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): username = user_input[CONF_USERNAME] return await self._create_client(username, password=user_input[CONF_PASSWORD]) - 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 MELCloud.""" 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 MELCloud.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/melnor/config_flow.py b/homeassistant/components/melnor/config_flow.py index 7aad59acf7b..223b30c7bb3 100644 --- a/homeassistant/components/melnor/config_flow.py +++ b/homeassistant/components/melnor/config_flow.py @@ -6,16 +6,15 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.bluetooth import async_discovered_service_info from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ADDRESS -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN, MANUFACTURER_DATA_START, MANUFACTURER_ID -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MelnorConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for melnor.""" VERSION = 1 @@ -25,7 +24,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._discovered_address: str self._discovered_addresses: list[str] = [] - def _create_entry(self, address: str) -> FlowResult: + def _create_entry(self, address: str) -> ConfigFlowResult: """Create an entry for a discovered device.""" return self.async_create_entry( @@ -37,7 +36,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 user-confirmation of discovered device.""" if user_input is not None: @@ -50,7 +49,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_bluetooth( self, discovery_info: BluetoothServiceInfoBleak - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by Bluetooth discovery.""" address = discovery_info.address @@ -65,7 +64,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_pick_device( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the step to pick discovered device.""" if user_input is not None: @@ -108,7 +107,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.""" return await self.async_step_pick_device() diff --git a/homeassistant/components/met/config_flow.py b/homeassistant/components/met/config_flow.py index ac614e4691b..2afe6f8cd30 100644 --- a/homeassistant/components/met/config_flow.py +++ b/homeassistant/components/met/config_flow.py @@ -5,8 +5,13 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import OptionsFlowWithConfigEntry +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, + OptionsFlowWithConfigEntry, +) from homeassistant.const import ( CONF_ELEVATION, CONF_LATITUDE, @@ -15,7 +20,6 @@ from homeassistant.const import ( UnitOfLength, ) from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from homeassistant.helpers.selector import ( NumberSelector, @@ -47,7 +51,7 @@ def configured_instances(hass: HomeAssistant) -> set[str]: def _get_data_schema( - hass: HomeAssistant, config_entry: config_entries.ConfigEntry | None = None + hass: HomeAssistant, config_entry: ConfigEntry | None = None ) -> vol.Schema: """Get a schema with default values.""" # If tracking home or no config entry is passed in, default value come from Home location @@ -91,14 +95,14 @@ def _get_data_schema( ) -class MetConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MetConfigFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Met component.""" 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 = {} @@ -120,7 +124,7 @@ class MetConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_onboarding( self, data: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a flow initialized by onboarding.""" # Don't create entry if latitude or longitude isn't set. # Also, filters out our onboarding default location. @@ -137,8 +141,8 @@ class MetConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, - ) -> config_entries.OptionsFlow: + config_entry: ConfigEntry, + ) -> OptionsFlow: """Get the options flow for Met.""" return MetOptionsFlowHandler(config_entry) @@ -148,7 +152,7 @@ class MetOptionsFlowHandler(OptionsFlowWithConfigEntry): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Configure options for Met.""" if user_input is not None: diff --git a/homeassistant/components/met_eireann/config_flow.py b/homeassistant/components/met_eireann/config_flow.py index b4c0102b97e..d1e49e4961e 100644 --- a/homeassistant/components/met_eireann/config_flow.py +++ b/homeassistant/components/met_eireann/config_flow.py @@ -3,22 +3,21 @@ 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_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME -from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv from .const import DOMAIN, HOME_LOCATION_NAME -class MetEireannFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MetEireannFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Met Eireann component.""" 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 user_input is not None: # Check if an identical entity is already configured diff --git a/homeassistant/components/meteo_france/config_flow.py b/homeassistant/components/meteo_france/config_flow.py index a3001ee25c0..695b0c9b353 100644 --- a/homeassistant/components/meteo_france/config_flow.py +++ b/homeassistant/components/meteo_france/config_flow.py @@ -8,18 +8,16 @@ from meteofrance_api.client import MeteoFranceClient from meteofrance_api.model import Place import voluptuous as vol -from homeassistant import config_entries -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import CONF_CITY, DOMAIN _LOGGER = logging.getLogger(__name__) -class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MeteoFranceFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Meteo-France config flow.""" VERSION = 1 @@ -33,7 +31,7 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None, errors: dict[str, str] | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the setup form to the user.""" if user_input is None: @@ -49,7 +47,7 @@ class MeteoFranceFlowHandler(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: dict[str, str] = {} @@ -83,7 +81,7 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_cities( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Step where the user choose the city from the API search results.""" if not user_input: if len(self.places) > 1 and self.source != SOURCE_IMPORT: diff --git a/homeassistant/components/meteoclimatic/config_flow.py b/homeassistant/components/meteoclimatic/config_flow.py index 49be3889ead..3067368319a 100644 --- a/homeassistant/components/meteoclimatic/config_flow.py +++ b/homeassistant/components/meteoclimatic/config_flow.py @@ -5,14 +5,14 @@ from meteoclimatic import MeteoclimaticClient from meteoclimatic.exceptions import MeteoclimaticError, StationNotFound import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow from .const import CONF_STATION_CODE, DOMAIN _LOGGER = logging.getLogger(__name__) -class MeteoclimaticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MeteoclimaticFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Meteoclimatic config flow.""" VERSION = 1 diff --git a/homeassistant/components/metoffice/config_flow.py b/homeassistant/components/metoffice/config_flow.py index 3cf3b0fcda0..0677ae5e44c 100644 --- a/homeassistant/components/metoffice/config_flow.py +++ b/homeassistant/components/metoffice/config_flow.py @@ -7,9 +7,10 @@ from typing import Any import datapoint import voluptuous as vol -from homeassistant import config_entries, core, exceptions +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.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv from .const import DOMAIN @@ -18,9 +19,7 @@ from .helpers import fetch_site _LOGGER = logging.getLogger(__name__) -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 that the user input allows us to connect to DataPoint. Data has the keys from DATA_SCHEMA with values provided by the user. @@ -41,14 +40,14 @@ async def validate_input( return {"site_name": site.name} -class MetOfficeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MetOfficeConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Met Office weather integration.""" VERSION = 1 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: @@ -87,5 +86,5 @@ class MetOfficeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" diff --git a/homeassistant/components/microbees/config_flow.py b/homeassistant/components/microbees/config_flow.py index fb0b5faa020..2eaed8dbafc 100644 --- a/homeassistant/components/microbees/config_flow.py +++ b/homeassistant/components/microbees/config_flow.py @@ -7,7 +7,6 @@ from microBeesPy import MicroBees, MicroBeesException from homeassistant import config_entries from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client, config_entry_oauth2_flow from .const import DOMAIN @@ -32,7 +31,9 @@ class OAuth2FlowHandler( scopes = ["read", "write"] return {"scope": " ".join(scopes)} - async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult: + async def async_oauth_create_entry( + self, data: dict[str, Any] + ) -> config_entries.ConfigFlowResult: """Create an oauth config entry or update existing entry for reauth.""" microbees = MicroBees( @@ -61,7 +62,9 @@ class OAuth2FlowHandler( return self.async_abort(reason="reauth_successful") return self.async_abort(reason="wrong_account") - async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> config_entries.ConfigFlowResult: """Perform reauth upon an API authentication error.""" self.reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -70,7 +73,7 @@ class OAuth2FlowHandler( async def async_step_reauth_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> config_entries.ConfigFlowResult: """Confirm reauth dialog.""" if user_input is None: return self.async_show_form(step_id="reauth_confirm") diff --git a/homeassistant/components/mikrotik/config_flow.py b/homeassistant/components/mikrotik/config_flow.py index 84b334c5f8f..d2a7c5673b0 100644 --- a/homeassistant/components/mikrotik/config_flow.py +++ b/homeassistant/components/mikrotik/config_flow.py @@ -6,7 +6,12 @@ from typing import Any import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -15,7 +20,6 @@ from homeassistant.const import ( CONF_VERIFY_SSL, ) from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from .const import ( CONF_ARP_PING, @@ -30,23 +34,23 @@ from .errors import CannotConnect, LoginError from .hub import get_api -class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MikrotikFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Mikrotik config flow.""" VERSION = 1 - _reauth_entry: config_entries.ConfigEntry | None + _reauth_entry: ConfigEntry | None @staticmethod @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> MikrotikOptionsFlowHandler: """Get the options flow for this handler.""" return MikrotikOptionsFlowHandler(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: @@ -78,7 +82,7 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_reauth(self, data: Mapping[str, Any]) -> FlowResult: + async def async_step_reauth(self, 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 +91,7 @@ class MikrotikFlowHandler(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 @@ -122,22 +126,22 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) -class MikrotikOptionsFlowHandler(config_entries.OptionsFlow): +class MikrotikOptionsFlowHandler(OptionsFlow): """Handle Mikrotik options.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize Mikrotik options flow.""" self.config_entry = config_entry async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the Mikrotik options.""" return await self.async_step_device_tracker() async def async_step_device_tracker( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the device tracker options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/mill/config_flow.py b/homeassistant/components/mill/config_flow.py index 9f7dd5d5cdb..ce99f6cab65 100644 --- a/homeassistant/components/mill/config_flow.py +++ b/homeassistant/components/mill/config_flow.py @@ -3,14 +3,14 @@ from mill import Mill from mill_local import Mill as MillLocal import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import CLOUD, CONNECTION_TYPE, DOMAIN, LOCAL -class MillConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MillConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Mill integration.""" VERSION = 1 diff --git a/homeassistant/components/minecraft_server/config_flow.py b/homeassistant/components/minecraft_server/config_flow.py index 022b7ed3991..b870c032b1e 100644 --- a/homeassistant/components/minecraft_server/config_flow.py +++ b/homeassistant/components/minecraft_server/config_flow.py @@ -6,9 +6,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_ADDRESS, CONF_NAME, CONF_TYPE -from homeassistant.data_entry_flow import FlowResult from .api import MinecraftServer, MinecraftServerAddressError, MinecraftServerType from .const import DEFAULT_NAME, DOMAIN @@ -25,7 +24,7 @@ class MinecraftServerConfigFlow(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] = {} @@ -66,7 +65,7 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None, errors: dict[str, str] | None = None, - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the setup form to the user.""" if user_input is None: user_input = {} diff --git a/homeassistant/components/mjpeg/config_flow.py b/homeassistant/components/mjpeg/config_flow.py index 024766f4c63..c5c3938aff4 100644 --- a/homeassistant/components/mjpeg/config_flow.py +++ b/homeassistant/components/mjpeg/config_flow.py @@ -10,7 +10,12 @@ from requests.auth import HTTPBasicAuth, HTTPDigestAuth from requests.exceptions import HTTPError, Timeout 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_AUTHENTICATION, CONF_NAME, @@ -21,7 +26,6 @@ from homeassistant.const import ( HTTP_DIGEST_AUTHENTICATION, ) from homeassistant.core import HomeAssistant, callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError from .const import CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, DOMAIN, LOGGER @@ -140,7 +144,7 @@ class MJPEGFlowHandler(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: dict[str, str] = {} @@ -184,7 +188,7 @@ class MJPEGOptionsFlowHandler(OptionsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage MJPEG IP Camera options.""" errors: dict[str, str] = {} diff --git a/homeassistant/components/moat/config_flow.py b/homeassistant/components/moat/config_flow.py index 4e522a81c73..ce400b6851d 100644 --- a/homeassistant/components/moat/config_flow.py +++ b/homeassistant/components/moat/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 MoatConfigFlow(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 MoatConfigFlow(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 MoatConfigFlow(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/mobile_app/config_flow.py b/homeassistant/components/mobile_app/config_flow.py index 246c433672b..46b0c9ba09f 100644 --- a/homeassistant/components/mobile_app/config_flow.py +++ b/homeassistant/components/mobile_app/config_flow.py @@ -1,15 +1,15 @@ """Config flow for Mobile App.""" import uuid -from homeassistant import config_entries from homeassistant.components import person +from homeassistant.config_entries import ConfigFlow from homeassistant.const import ATTR_DEVICE_ID from homeassistant.helpers import entity_registry as er from .const import ATTR_APP_ID, ATTR_DEVICE_NAME, CONF_USER_ID, DOMAIN -class MobileAppFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MobileAppFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Mobile App config flow.""" VERSION = 1 diff --git a/homeassistant/components/modem_callerid/config_flow.py b/homeassistant/components/modem_callerid/config_flow.py index fac20073fe9..52bbf51fc61 100644 --- a/homeassistant/components/modem_callerid/config_flow.py +++ b/homeassistant/components/modem_callerid/config_flow.py @@ -8,10 +8,9 @@ import serial.tools.list_ports from serial.tools.list_ports_common import ListPortInfo import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import usb +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE, CONF_NAME -from homeassistant.data_entry_flow import FlowResult from .const import DEFAULT_NAME, DOMAIN, EXCEPTIONS @@ -23,14 +22,16 @@ def _generate_unique_id(port: ListPortInfo) -> str: return f"{port.vid}:{port.pid}_{port.serial_number}_{port.manufacturer}_{port.description}" -class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class PhoneModemFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for Phone Modem.""" def __init__(self) -> None: """Set up flow instance.""" self._device: str | None = None - async def async_step_usb(self, discovery_info: usb.UsbServiceInfo) -> FlowResult: + async def async_step_usb( + self, discovery_info: usb.UsbServiceInfo + ) -> ConfigFlowResult: """Handle USB Discovery.""" dev_path = discovery_info.device unique_id = f"{discovery_info.vid}:{discovery_info.pid}_{discovery_info.serial_number}_{discovery_info.manufacturer}_{discovery_info.description}" @@ -44,7 +45,7 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_usb_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle USB Discovery confirmation.""" if user_input is not None: return self.async_create_entry( @@ -56,7 +57,7 @@ class PhoneModemFlowHandler(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: dict[str, str] | None = {} if self._async_in_progress(): diff --git a/homeassistant/components/modern_forms/config_flow.py b/homeassistant/components/modern_forms/config_flow.py index f8f3e2f1dc1..80e8bf5cf77 100644 --- a/homeassistant/components/modern_forms/config_flow.py +++ b/homeassistant/components/modern_forms/config_flow.py @@ -7,9 +7,8 @@ from aiomodernforms import ModernFormsConnectionError, ModernFormsDevice import voluptuous as vol from homeassistant.components import zeroconf -from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow +from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN @@ -22,13 +21,13 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle setup by user for Modern Forms integration.""" return await self._handle_config_flow(user_input) async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.hostname.rstrip(".") name, _ = host.rsplit(".") @@ -47,13 +46,13 @@ class ModernFormsFlowHandler(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.""" return await self._handle_config_flow(user_input) async def _handle_config_flow( self, user_input: dict[str, Any] | None = None, prepare: bool = False - ) -> FlowResult: + ) -> ConfigFlowResult: """Config flow handler for ModernForms.""" source = self.context.get("source") @@ -97,7 +96,7 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN): data={CONF_HOST: user_input[CONF_HOST], CONF_MAC: user_input[CONF_MAC]}, ) - 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", @@ -105,7 +104,7 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN): errors=errors or {}, ) - def _show_confirm_dialog(self, errors: dict | None = None) -> FlowResult: + def _show_confirm_dialog(self, errors: dict | None = None) -> ConfigFlowResult: """Show the confirm dialog to the user.""" name = self.context.get(CONF_NAME) return self.async_show_form( diff --git a/homeassistant/components/moehlenhoff_alpha2/config_flow.py b/homeassistant/components/moehlenhoff_alpha2/config_flow.py index a4bdfd71cce..64cad25f461 100644 --- a/homeassistant/components/moehlenhoff_alpha2/config_flow.py +++ b/homeassistant/components/moehlenhoff_alpha2/config_flow.py @@ -6,9 +6,8 @@ import aiohttp from moehlenhoff_alpha2 import Alpha2Base import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -43,7 +42,7 @@ class Alpha2BaseConfigFlow(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: diff --git a/homeassistant/components/monoprice/config_flow.py b/homeassistant/components/monoprice/config_flow.py index 9c659d4f733..43286946b7d 100644 --- a/homeassistant/components/monoprice/config_flow.py +++ b/homeassistant/components/monoprice/config_flow.py @@ -7,8 +7,10 @@ from pymonoprice import get_monoprice from serial import SerialException import voluptuous as vol -from homeassistant import config_entries, core, exceptions +from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.const import CONF_PORT +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError from .const import ( CONF_SOURCE_1, @@ -37,7 +39,7 @@ OPTIONS_FOR_DATA = {vol.Optional(source): str for source in SOURCES} DATA_SCHEMA = vol.Schema({vol.Required(CONF_PORT): str, **OPTIONS_FOR_DATA}) -@core.callback +@callback def _sources_from_config(data): sources_config = { str(idx + 1): data.get(source) for idx, source in enumerate(SOURCES) @@ -50,7 +52,7 @@ def _sources_from_config(data): } -async def validate_input(hass: core.HomeAssistant, data): +async def validate_input(hass: HomeAssistant, data): """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. @@ -67,7 +69,7 @@ async def validate_input(hass: core.HomeAssistant, data): return {CONF_PORT: data[CONF_PORT], CONF_SOURCES: sources} -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MonoPriceConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Monoprice 6-Zone Amplifier.""" VERSION = 1 @@ -91,15 +93,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) @staticmethod - @core.callback + @callback def async_get_options_flow( - config_entry: config_entries.ConfigEntry, + config_entry: ConfigEntry, ) -> MonopriceOptionsFlowHandler: """Define the config flow to handle options.""" return MonopriceOptionsFlowHandler(config_entry) -@core.callback +@callback def _key_for_source(index, source, previous_sources): if str(index) in previous_sources: key = vol.Optional( @@ -111,14 +113,14 @@ def _key_for_source(index, source, previous_sources): return key -class MonopriceOptionsFlowHandler(config_entries.OptionsFlow): +class MonopriceOptionsFlowHandler(OptionsFlow): """Handle a Monoprice options flow.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, config_entry: ConfigEntry) -> None: """Initialize.""" self.config_entry = config_entry - @core.callback + @callback def _previous_sources(self): if CONF_SOURCES in self.config_entry.options: previous = self.config_entry.options[CONF_SOURCES] @@ -147,5 +149,5 @@ class MonopriceOptionsFlowHandler(config_entries.OptionsFlow): ) -class CannotConnect(exceptions.HomeAssistantError): +class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" diff --git a/homeassistant/components/moon/config_flow.py b/homeassistant/components/moon/config_flow.py index 08b2a4995f1..76f1850d6e7 100644 --- a/homeassistant/components/moon/config_flow.py +++ b/homeassistant/components/moon/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 DEFAULT_NAME, DOMAIN @@ -16,7 +15,7 @@ class MoonConfigFlow(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") diff --git a/homeassistant/components/mopeka/config_flow.py b/homeassistant/components/mopeka/config_flow.py index 54a2e7bcaf3..1bd79c1a20d 100644 --- a/homeassistant/components/mopeka/config_flow.py +++ b/homeassistant/components/mopeka/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 MopekaConfigFlow(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 MopekaConfigFlow(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 MopekaConfigFlow(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/motion_blinds/config_flow.py b/homeassistant/components/motion_blinds/config_flow.py index 588d470bb6c..0d63a2e413d 100644 --- a/homeassistant/components/motion_blinds/config_flow.py +++ b/homeassistant/components/motion_blinds/config_flow.py @@ -6,11 +6,15 @@ from typing import Any from motionblinds import MotionDiscovery, MotionGateway import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import dhcp +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import CONF_API_KEY, CONF_HOST from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.device_registry import format_mac from .const import ( @@ -30,16 +34,16 @@ CONFIG_SCHEMA = vol.Schema( ) -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.""" errors: dict[str, str] = {} if user_input is not None: @@ -61,7 +65,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow): ) -class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MotionBlindsFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Motionblinds config flow.""" VERSION = 1 @@ -75,12 +79,14 @@ class MotionBlindsFlowHandler(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_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> ConfigFlowResult: """Handle discovery via dhcp.""" mac_address = format_mac(discovery_info.macaddress).replace(":", "") await self.async_set_unique_id(mac_address) @@ -107,7 +113,7 @@ class MotionBlindsFlowHandler(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: @@ -136,7 +142,7 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_select( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle multiple motion gateways found.""" if user_input is not None: self._host = user_input["select_ip"] @@ -148,7 +154,7 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_connect( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Connect to the Motion Gateway.""" errors: dict[str, str] = {} if user_input is not None: diff --git a/homeassistant/components/motioneye/config_flow.py b/homeassistant/components/motioneye/config_flow.py index 4ab4761fe0b..fba66c45b8b 100644 --- a/homeassistant/components/motioneye/config_flow.py +++ b/homeassistant/components/motioneye/config_flow.py @@ -16,11 +16,11 @@ from homeassistant.config_entries import ( SOURCE_REAUTH, ConfigEntry, ConfigFlow, + ConfigFlowResult, OptionsFlow, ) from homeassistant.const import CONF_SOURCE, CONF_URL, CONF_WEBHOOK_ID from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -47,12 +47,12 @@ class MotionEyeConfigFlow(ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle the initial step.""" def _get_form( user_input: dict[str, Any], errors: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the form to the user.""" url_schema: dict[vol.Required, type[str]] = {} if not self._hassio_discovery: @@ -157,11 +157,15 @@ class MotionEyeConfigFlow(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: """Handle a reauthentication flow.""" return await self.async_step_user() - async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult: + async def async_step_hassio( + self, discovery_info: HassioServiceInfo + ) -> ConfigFlowResult: """Handle Supervisor discovery.""" self._hassio_discovery = discovery_info.config await self._async_handle_discovery_without_unique_id() @@ -170,7 +174,7 @@ class MotionEyeConfigFlow(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 and self._hassio_discovery is not None: return self.async_show_form( @@ -196,7 +200,7 @@ class MotionEyeOptionsFlow(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) diff --git a/homeassistant/components/motionmount/config_flow.py b/homeassistant/components/motionmount/config_flow.py index a593b30201e..3b0c8ffd830 100644 --- a/homeassistant/components/motionmount/config_flow.py +++ b/homeassistant/components/motionmount/config_flow.py @@ -6,10 +6,13 @@ from typing import Any import motionmount import voluptuous as vol -from homeassistant import config_entries from homeassistant.components import zeroconf +from homeassistant.config_entries import ( + DEFAULT_DISCOVERY_UNIQUE_ID, + ConfigFlow, + ConfigFlowResult, +) from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_UUID -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.device_registry import format_mac from .const import DOMAIN, EMPTY_MAC @@ -23,7 +26,7 @@ _LOGGER = logging.getLogger(__name__) # 3. New CE but old Pro FW -> It doesn't supply the mac using DNS-SD but we can read it (returning the EMPTY_MAC) # 4. New CE and new Pro FW -> Both DNS-SD and a read gives us the mac # If we can't get the mac, we use DEFAULT_DISCOVERY_UNIQUE_ID as an ID, so we can always configure a single MotionMount. Most households will only have a single MotionMount -class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MotionMountFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Vogel's MotionMount config flow.""" VERSION = 1 @@ -34,7 +37,7 @@ class MotionMountFlowHandler(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 user_input is None: return self._show_setup_form() @@ -55,13 +58,13 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_abort(reason="already_configured") # Otherwise we try to continue with the generic uid - info[CONF_UUID] = config_entries.DEFAULT_DISCOVERY_UNIQUE_ID + info[CONF_UUID] = DEFAULT_DISCOVERY_UNIQUE_ID # If the device mac is valid we use it, otherwise we use the default id if info.get(CONF_UUID, EMPTY_MAC) != EMPTY_MAC: unique_id = info[CONF_UUID] else: - unique_id = config_entries.DEFAULT_DISCOVERY_UNIQUE_ID + unique_id = DEFAULT_DISCOVERY_UNIQUE_ID name = info.get(CONF_NAME, user_input[CONF_HOST]) @@ -77,7 +80,7 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle zeroconf discovery.""" # Extract information from discovery @@ -137,7 +140,7 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_zeroconf_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Handle a confirmation flow initiated by zeroconf.""" if user_input is None: return self.async_show_form( @@ -162,7 +165,9 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return {CONF_UUID: format_mac(mm.mac.hex()), CONF_NAME: mm.name} - def _show_setup_form(self, errors: dict[str, str] | None = None) -> FlowResult: + def _show_setup_form( + self, errors: dict[str, str] | None = None + ) -> ConfigFlowResult: """Show the setup form to the user.""" return self.async_show_form( step_id="user", diff --git a/homeassistant/components/mqtt/config_flow.py b/homeassistant/components/mqtt/config_flow.py index 4f46dffec11..96ee6596f5a 100644 --- a/homeassistant/components/mqtt/config_flow.py +++ b/homeassistant/components/mqtt/config_flow.py @@ -14,7 +14,12 @@ import voluptuous as vol from homeassistant.components.file_upload import process_uploaded_file from homeassistant.components.hassio import HassioServiceInfo -from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow +from homeassistant.config_entries import ( + ConfigEntry, + ConfigFlow, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.const import ( CONF_CLIENT_ID, CONF_DISCOVERY, @@ -26,7 +31,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.json import json_dumps from homeassistant.helpers.selector import ( @@ -171,7 +175,7 @@ class FlowHandler(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") @@ -180,7 +184,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_broker( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm the setup.""" errors: dict[str, str] = {} fields: OrderedDict[Any, Any] = OrderedDict() @@ -211,7 +215,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): step_id="broker", data_schema=vol.Schema(fields), errors=errors ) - async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult: + async def async_step_hassio( + self, discovery_info: HassioServiceInfo + ) -> ConfigFlowResult: """Receive a Hass.io discovery.""" await self._async_handle_discovery_without_unique_id() @@ -221,7 +227,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_hassio_confirm( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Confirm a Hass.io discovery.""" errors: dict[str, str] = {} if TYPE_CHECKING: @@ -265,13 +271,13 @@ class MQTTOptionsFlowHandler(OptionsFlow): self.broker_config: dict[str, str | int] = {} self.options = config_entry.options - async def async_step_init(self, user_input: None = None) -> FlowResult: + async def async_step_init(self, user_input: None = None) -> ConfigFlowResult: """Manage the MQTT options.""" return await self.async_step_broker() async def async_step_broker( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the MQTT broker configuration.""" errors: dict[str, str] = {} fields: OrderedDict[Any, Any] = OrderedDict() @@ -304,7 +310,7 @@ class MQTTOptionsFlowHandler(OptionsFlow): async def async_step_options( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Manage the MQTT options.""" errors = {} current_config = self.config_entry.data diff --git a/homeassistant/components/mullvad/config_flow.py b/homeassistant/components/mullvad/config_flow.py index ad045dbb54c..f576dbc08af 100644 --- a/homeassistant/components/mullvad/config_flow.py +++ b/homeassistant/components/mullvad/config_flow.py @@ -1,18 +1,17 @@ """Config flow for Mullvad VPN integration.""" from mullvad_api import MullvadAPI, MullvadAPIError -from homeassistant import config_entries -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from .const import DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MullvadConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Mullvad VPN.""" VERSION = 1 - async def async_step_user(self, user_input=None) -> FlowResult: + async def async_step_user(self, user_input=None) -> ConfigFlowResult: """Handle the initial step.""" self._async_abort_entries_match() diff --git a/homeassistant/components/mutesync/config_flow.py b/homeassistant/components/mutesync/config_flow.py index 21bbcfe69bb..75c15ff2f50 100644 --- a/homeassistant/components/mutesync/config_flow.py +++ b/homeassistant/components/mutesync/config_flow.py @@ -8,9 +8,8 @@ import aiohttp import mutesync import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult 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 @@ -38,14 +37,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, return token -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MuteSyncConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for mütesync.""" 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/myq/config_flow.py b/homeassistant/components/myq/config_flow.py index 27bb1c4b9e5..46b3d7afcc5 100644 --- a/homeassistant/components/myq/config_flow.py +++ b/homeassistant/components/myq/config_flow.py @@ -1,11 +1,11 @@ """Config flow for MyQ integration.""" -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow from . import DOMAIN -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MyQConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for MyQ.""" VERSION = 1 diff --git a/homeassistant/components/mysensors/config_flow.py b/homeassistant/components/mysensors/config_flow.py index fdf056c6c06..c4926696643 100644 --- a/homeassistant/components/mysensors/config_flow.py +++ b/homeassistant/components/mysensors/config_flow.py @@ -11,16 +11,14 @@ from awesomeversion import ( ) import voluptuous as vol -from homeassistant import config_entries from homeassistant.components.mqtt import ( DOMAIN as MQTT_DOMAIN, valid_publish_topic, valid_subscribe_topic, ) -from homeassistant.config_entries import ConfigEntry +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE from homeassistant.core import callback -from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import selector import homeassistant.helpers.config_validation as cv @@ -120,7 +118,7 @@ def _is_same_device( return True -class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class MySensorsConfigFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" def __init__(self) -> None: @@ -129,13 +127,13 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Create a config entry from frontend user input.""" return await self.async_step_select_gateway_type() async def async_step_select_gateway_type( self, user_input: dict[str, str] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Show the select gateway type menu.""" return self.async_show_menu( step_id="select_gateway_type", @@ -144,7 +142,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_gw_serial( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Create config entry for a serial gateway.""" gw_type = self._gw_type = CONF_GATEWAY_TYPE_SERIAL errors: dict[str, str] = {} @@ -173,7 +171,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_gw_tcp( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Create a config entry for a tcp gateway.""" gw_type = self._gw_type = CONF_GATEWAY_TYPE_TCP errors: dict[str, str] = {} @@ -207,7 +205,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_gw_mqtt( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> ConfigFlowResult: """Create a config entry for a mqtt gateway.""" # Naive check that doesn't consider config entry state. if MQTT_DOMAIN not in self.hass.config.components: @@ -262,7 +260,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) @callback - def _async_create_entry(self, user_input: dict[str, Any]) -> FlowResult: + def _async_create_entry(self, user_input: dict[str, Any]) -> ConfigFlowResult: """Create the config entry.""" return self.async_create_entry( title=f"{user_input[CONF_DEVICE]}", diff --git a/homeassistant/components/mystrom/config_flow.py b/homeassistant/components/mystrom/config_flow.py index 6b2fe85bfe8..dc603a16c34 100644 --- a/homeassistant/components/mystrom/config_flow.py +++ b/homeassistant/components/mystrom/config_flow.py @@ -8,9 +8,8 @@ import pymystrom from pymystrom.exceptions import MyStromConnectionError import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME -from homeassistant.data_entry_flow import FlowResult from .const import DOMAIN @@ -26,14 +25,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema( ) -class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): +class MyStromConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for myStrom.""" 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] = {} diff --git a/homeassistant/components/myuplink/config_flow.py b/homeassistant/components/myuplink/config_flow.py index c108aa00ebe..fee571effa6 100644 --- a/homeassistant/components/myuplink/config_flow.py +++ b/homeassistant/components/myuplink/config_flow.py @@ -3,8 +3,7 @@ from collections.abc import Mapping import logging from typing import Any -from homeassistant.config_entries import ConfigEntry -from homeassistant.data_entry_flow import FlowResult +from homeassistant.config_entries import ConfigEntry, ConfigFlowResult from homeassistant.helpers import config_entry_oauth2_flow from .const import DOMAIN, OAUTH2_SCOPES @@ -29,7 +28,9 @@ class OAuth2FlowHandler( """Extra data that needs to be appended to the authorize url.""" return {"scope": " ".join(OAUTH2_SCOPES)} - 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.config_entry_reauth = self.hass.config_entries.async_get_entry( self.context["entry_id"] @@ -38,7 +39,7 @@ class OAuth2FlowHandler( async def async_step_reauth_confirm( self, user_input: Mapping[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( @@ -47,7 +48,7 @@ class OAuth2FlowHandler( return await self.async_step_user() - async def async_oauth_create_entry(self, data: dict) -> FlowResult: + async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult: """Create or update the config entry.""" if self.config_entry_reauth: return self.async_update_reload_and_abort(