From f2fde1b65e91842899fa58a367ec1ad507f64125 Mon Sep 17 00:00:00 2001 From: Stef Simoens Date: Sat, 11 Jan 2025 14:23:27 +0100 Subject: [PATCH] Dhcp,Ssdp,ZeroconfServiceInfo: avoid that type checking imports dhcp,ssdp,zeroconf Some users might not use the default_config and avoid loading dhcp, ssdp or zeroconf. Currently, due to type checking, dhcp, ssdp or zeroconf will still be imported. This patch avoids this import (while keeping the annotation) Methodology: - make sure that __future__.annotations and typing.TYPE_CHECKING are imported - check no other objects of the imported module are being used - move the import to a conditional import (if TYPE_CHECKING:) - only import homeassistant.components.{dhcp,ssdp,zeroconf}.{Dhcp,Ssdp,Zeroconf}ServiceInfo Signed-off-by: Stef Simoens --- .../components/airgradient/config_flow.py | 10 +++++++--- homeassistant/components/airzone/config_flow.py | 8 +++++--- .../components/androidtv_remote/config_flow.py | 8 +++++--- homeassistant/components/awair/config_flow.py | 9 ++++++--- homeassistant/components/axis/config_flow.py | 12 ++++++++---- homeassistant/components/baf/config_flow.py | 8 +++++--- .../components/bang_olufsen/config_flow.py | 6 ++++-- homeassistant/components/blebox/config_flow.py | 8 +++++--- homeassistant/components/bluesound/config_flow.py | 10 +++++++--- homeassistant/components/bond/config_flow.py | 8 +++++--- homeassistant/components/broadlink/config_flow.py | 10 +++++++--- homeassistant/components/brother/config_flow.py | 8 +++++--- .../components/cambridge_audio/config_flow.py | 10 +++++++--- homeassistant/components/daikin/config_flow.py | 8 +++++--- homeassistant/components/devialet/config_flow.py | 8 +++++--- homeassistant/components/dlink/config_flow.py | 8 +++++--- homeassistant/components/doorbird/config_flow.py | 8 +++++--- .../components/eheimdigital/config_flow.py | 4 +++- homeassistant/components/elgato/config_flow.py | 9 ++++++--- homeassistant/components/elmax/config_flow.py | 6 ++++-- homeassistant/components/emonitor/config_flow.py | 10 +++++++--- .../components/enphase_envoy/config_flow.py | 6 ++++-- homeassistant/components/esphome/config_flow.py | 9 ++++++--- homeassistant/components/flux_led/config_flow.py | 8 +++++--- .../components/forked_daapd/config_flow.py | 10 +++++++--- homeassistant/components/freebox/config_flow.py | 10 +++++++--- homeassistant/components/fronius/config_flow.py | 6 ++++-- .../components/frontier_silicon/config_flow.py | 8 +++++--- .../components/fully_kiosk/config_flow.py | 6 ++++-- homeassistant/components/goalzero/config_flow.py | 8 +++++--- homeassistant/components/gogogate2/config_flow.py | 9 ++++++--- homeassistant/components/guardian/config_flow.py | 11 +++++++---- homeassistant/components/homewizard/config_flow.py | 11 +++++++---- homeassistant/components/hue/config_flow.py | 10 ++++++---- .../hunterdouglas_powerview/config_flow.py | 11 +++++++---- homeassistant/components/insteon/config_flow.py | 9 ++++++--- .../components/intellifire/config_flow.py | 6 ++++-- homeassistant/components/ipp/config_flow.py | 8 +++++--- homeassistant/components/isy994/config_flow.py | 9 ++++++--- homeassistant/components/kodi/config_flow.py | 8 +++++--- homeassistant/components/lamarzocco/config_flow.py | 6 ++++-- homeassistant/components/lametric/config_flow.py | 6 ++++-- homeassistant/components/lektrico/config_flow.py | 6 ++++-- homeassistant/components/lifx/config_flow.py | 10 ++++++---- homeassistant/components/linkplay/config_flow.py | 10 +++++++--- homeassistant/components/lookin/config_flow.py | 8 +++++--- homeassistant/components/loqed/config_flow.py | 6 ++++-- .../components/lutron_caseta/config_flow.py | 10 ++++++---- homeassistant/components/matter/config_flow.py | 6 ++++-- .../components/modern_forms/config_flow.py | 8 +++++--- .../components/motion_blinds/config_flow.py | 8 +++++--- .../components/motionmount/config_flow.py | 10 +++++++--- .../components/music_assistant/config_flow.py | 6 ++++-- homeassistant/components/nam/config_flow.py | 8 +++++--- homeassistant/components/nanoleaf/config_flow.py | 9 ++++++--- homeassistant/components/nuki/config_flow.py | 10 +++++++--- homeassistant/components/nut/config_flow.py | 8 +++++--- homeassistant/components/obihai/config_flow.py | 10 ++++++---- homeassistant/components/octoprint/config_flow.py | 9 ++++++--- homeassistant/components/onkyo/config_flow.py | 10 +++++++--- homeassistant/components/onvif/config_flow.py | 8 +++++--- homeassistant/components/palazzetti/config_flow.py | 10 +++++++--- homeassistant/components/peblar/config_flow.py | 10 ++++++---- homeassistant/components/plugwise/config_flow.py | 6 ++++-- .../components/pure_energie/config_flow.py | 8 +++++--- homeassistant/components/qnap_qsw/config_flow.py | 8 +++++--- homeassistant/components/radiotherm/config_flow.py | 8 +++++--- .../components/rainmachine/config_flow.py | 12 +++++++----- homeassistant/components/reolink/config_flow.py | 8 +++++--- homeassistant/components/roku/config_flow.py | 9 ++++++--- homeassistant/components/romy/config_flow.py | 8 ++++++-- homeassistant/components/roomba/config_flow.py | 11 +++++++---- .../components/russound_rio/config_flow.py | 8 +++++--- .../components/ruuvi_gateway/config_flow.py | 8 +++++--- homeassistant/components/samsungtv/config_flow.py | 12 ++++++++---- .../components/screenlogic/config_flow.py | 8 +++++--- homeassistant/components/shelly/config_flow.py | 6 ++++-- .../components/slide_local/config_flow.py | 6 ++++-- homeassistant/components/smappee/config_flow.py | 10 +++++++--- homeassistant/components/smlight/config_flow.py | 8 +++++--- .../components/somfy_mylink/config_flow.py | 8 +++++--- homeassistant/components/sonos/config_flow.py | 10 ++++++++-- homeassistant/components/soundtouch/config_flow.py | 8 ++++++-- homeassistant/components/squeezebox/config_flow.py | 6 ++++-- homeassistant/components/steamist/config_flow.py | 8 +++++--- .../components/system_bridge/config_flow.py | 8 +++++--- homeassistant/components/tailwind/config_flow.py | 10 ++++++---- homeassistant/components/technove/config_flow.py | 11 ++++++++--- .../components/tesla_wall_connector/config_flow.py | 8 +++++--- homeassistant/components/tolo/config_flow.py | 8 +++++--- homeassistant/components/tplink/config_flow.py | 7 +++++-- homeassistant/components/twinkly/config_flow.py | 8 +++++--- .../components/unifiprotect/config_flow.py | 11 +++++++---- homeassistant/components/vicare/config_flow.py | 8 +++++--- homeassistant/components/vizio/config_flow.py | 8 +++++--- homeassistant/components/volumio/config_flow.py | 8 +++++--- homeassistant/components/wiz/config_flow.py | 9 ++++++--- homeassistant/components/wled/config_flow.py | 9 ++++++--- homeassistant/components/wmspro/config_flow.py | 13 +++++++------ homeassistant/components/wyoming/config_flow.py | 8 +++++--- .../components/xiaomi_aqara/config_flow.py | 10 +++++++--- .../components/xiaomi_miio/config_flow.py | 8 +++++--- homeassistant/components/yeelight/config_flow.py | 14 +++++++++----- homeassistant/components/zwave_js/config_flow.py | 6 ++++-- homeassistant/components/zwave_me/config_flow.py | 5 ++++- 105 files changed, 582 insertions(+), 310 deletions(-) diff --git a/homeassistant/components/airgradient/config_flow.py b/homeassistant/components/airgradient/config_flow.py index 70fa8a1755bf5..758bb3eecbea5 100644 --- a/homeassistant/components/airgradient/config_flow.py +++ b/homeassistant/components/airgradient/config_flow.py @@ -1,6 +1,8 @@ """Config flow for Airgradient.""" -from typing import Any +from __future__ import annotations + +from typing import TYPE_CHECKING, Any from airgradient import ( AirGradientClient, @@ -11,13 +13,15 @@ from awesomeversion import AwesomeVersion import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MODEL from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + MIN_VERSION = AwesomeVersion("3.1.1") @@ -37,7 +41,7 @@ async def set_configuration_source(self) -> None: await self.client.set_configuration_control(ConfigurationControl.LOCAL) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.data[CONF_HOST] = host = discovery_info.host diff --git a/homeassistant/components/airzone/config_flow.py b/homeassistant/components/airzone/config_flow.py index 406fd72a6db3d..c8b690600bfc7 100644 --- a/homeassistant/components/airzone/config_flow.py +++ b/homeassistant/components/airzone/config_flow.py @@ -3,14 +3,13 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aioairzone.const import DEFAULT_PORT, DEFAULT_SYSTEM_ID from aioairzone.exceptions import AirzoneError, InvalidSystem from aioairzone.localapi import AirzoneLocalApi, ConnectionOptions import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_ID, CONF_PORT from homeassistant.data_entry_flow import AbortFlow @@ -19,6 +18,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema( @@ -93,7 +95,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle DHCP discovery.""" self._discovered_ip = discovery_info.ip diff --git a/homeassistant/components/androidtv_remote/config_flow.py b/homeassistant/components/androidtv_remote/config_flow.py index 4df2524788177..00bc05f7dc657 100644 --- a/homeassistant/components/androidtv_remote/config_flow.py +++ b/homeassistant/components/androidtv_remote/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from androidtvremote2 import ( AndroidTVRemote, @@ -14,7 +14,6 @@ ) import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( SOURCE_REAUTH, ConfigEntry, @@ -35,6 +34,9 @@ from .const import CONF_APP_ICON, CONF_APP_NAME, CONF_APPS, CONF_ENABLE_IME, DOMAIN from .helpers import create_api, get_enable_ime +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) APPS_NEW_ID = "NewApp" @@ -142,7 +144,7 @@ async def async_step_pair( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" _LOGGER.debug("Android TV device found via zeroconf: %s", discovery_info) diff --git a/homeassistant/components/awair/config_flow.py b/homeassistant/components/awair/config_flow.py index 88985b0db10d5..116aa84fc12f6 100644 --- a/homeassistant/components/awair/config_flow.py +++ b/homeassistant/components/awair/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, Self, cast +from typing import TYPE_CHECKING, Any, Self, cast from aiohttp.client_exceptions import ClientError from python_awair import Awair, AwairLocal, AwairLocalDevice @@ -11,7 +11,7 @@ from python_awair.user import AwairUser import voluptuous as vol -from homeassistant.components import onboarding, zeroconf +from homeassistant.components import onboarding from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ACCESS_TOKEN, CONF_DEVICE, CONF_HOST from homeassistant.core import callback @@ -19,6 +19,9 @@ from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class AwairFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Awair.""" @@ -29,7 +32,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): host: str async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index 592b1e2d41f7e..42b26ac4954be 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -5,12 +5,12 @@ from collections.abc import Mapping from ipaddress import ip_address from types import MappingProxyType -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urlsplit import voluptuous as vol -from homeassistant.components import dhcp, ssdp, zeroconf +from homeassistant.components import ssdp from homeassistant.config_entries import ( SOURCE_IGNORE, SOURCE_REAUTH, @@ -46,6 +46,10 @@ from .errors import AuthenticationRequired, CannotConnect from .hub import AxisHub, get_axis_api +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + AXIS_OUI = {"00:40:8c", "ac:cc:8e", "b8:a4:4f"} DEFAULT_PORT = 443 DEFAULT_PROTOCOL = "https" @@ -190,7 +194,7 @@ async def _redo_configuration( return await self.async_step_user() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a DHCP discovered Axis device.""" return await self._process_discovered_device( @@ -217,7 +221,7 @@ async def async_step_ssdp( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a Zeroconf discovered Axis device.""" return await self._process_discovered_device( diff --git a/homeassistant/components/baf/config_flow.py b/homeassistant/components/baf/config_flow.py index 0d56699e1cee7..728d2a7fe526d 100644 --- a/homeassistant/components/baf/config_flow.py +++ b/homeassistant/components/baf/config_flow.py @@ -4,19 +4,21 @@ from asyncio import timeout import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiobafi6 import Device, Service from aiobafi6.discovery import PORT import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS from .const import DOMAIN, RUN_TIMEOUT from .models import BAFDiscovery +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -44,7 +46,7 @@ def __init__(self) -> None: self.discovery: BAFDiscovery | None = None async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" if discovery_info.ip_address.version == 6: diff --git a/homeassistant/components/bang_olufsen/config_flow.py b/homeassistant/components/bang_olufsen/config_flow.py index e1c1c7ab53863..bbab65ef55dc6 100644 --- a/homeassistant/components/bang_olufsen/config_flow.py +++ b/homeassistant/components/bang_olufsen/config_flow.py @@ -3,14 +3,13 @@ from __future__ import annotations from ipaddress import AddressValueError, IPv4Address -from typing import Any, TypedDict +from typing import TYPE_CHECKING, Any, TypedDict from aiohttp.client_exceptions import ClientConnectorError from mozart_api.exceptions import ApiException from mozart_api.mozart_client import MozartClient import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MODEL from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig @@ -28,6 +27,9 @@ ) from .util import get_serial_number_from_jid +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class EntryData(TypedDict, total=False): """TypedDict for config_entry data.""" diff --git a/homeassistant/components/blebox/config_flow.py b/homeassistant/components/blebox/config_flow.py index 2221e35a81f81..c6c68fe84f528 100644 --- a/homeassistant/components/blebox/config_flow.py +++ b/homeassistant/components/blebox/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from blebox_uniapi.box import Box from blebox_uniapi.error import ( @@ -15,7 +15,6 @@ from blebox_uniapi.session import ApiHost import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -32,6 +31,9 @@ UNSUPPORTED_VERSION, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -84,7 +86,7 @@ def handle_step_exception( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" hass = self.hass diff --git a/homeassistant/components/bluesound/config_flow.py b/homeassistant/components/bluesound/config_flow.py index b5e31fb2ed712..e02ab74bb2dce 100644 --- a/homeassistant/components/bluesound/config_flow.py +++ b/homeassistant/components/bluesound/config_flow.py @@ -1,13 +1,14 @@ """Config flow for bluesound.""" +from __future__ import annotations + import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pyblu import Player, SyncStatus from pyblu.errors import PlayerUnreachableError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -16,6 +17,9 @@ from .media_player import DEFAULT_PORT from .utils import format_unique_id +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -72,7 +76,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" if discovery_info.port is not None: diff --git a/homeassistant/components/bond/config_flow.py b/homeassistant/components/bond/config_flow.py index a12d305725883..b9124bf2e9218 100644 --- a/homeassistant/components/bond/config_flow.py +++ b/homeassistant/components/bond/config_flow.py @@ -5,13 +5,12 @@ import contextlib from http import HTTPStatus import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientConnectionError, ClientResponseError from bond_async import Bond import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant @@ -21,6 +20,9 @@ from .const import DOMAIN from .utils import BondHub +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -97,7 +99,7 @@ async def _async_try_automatic_configure(self) -> None: self._discovered[CONF_NAME] = hub_name async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" name: str = discovery_info.name diff --git a/homeassistant/components/broadlink/config_flow.py b/homeassistant/components/broadlink/config_flow.py index c9b2fb4660853..24647c4f57067 100644 --- a/homeassistant/components/broadlink/config_flow.py +++ b/homeassistant/components/broadlink/config_flow.py @@ -1,11 +1,13 @@ """Config flow for Broadlink devices.""" +from __future__ import annotations + from collections.abc import Mapping import errno from functools import partial import logging import socket -from typing import Any +from typing import TYPE_CHECKING, Any import broadlink as blk from broadlink.exceptions import ( @@ -15,7 +17,6 @@ ) import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ( SOURCE_IMPORT, SOURCE_REAUTH, @@ -29,6 +30,9 @@ from .const import DEFAULT_PORT, DEFAULT_TIMEOUT, DEVICE_TYPES, DOMAIN from .helpers import format_mac +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -65,7 +69,7 @@ async def async_set_device( } async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" host = discovery_info.ip diff --git a/homeassistant/components/brother/config_flow.py b/homeassistant/components/brother/config_flow.py index d9130b96300b1..6a9f3acdcaec6 100644 --- a/homeassistant/components/brother/config_flow.py +++ b/homeassistant/components/brother/config_flow.py @@ -2,12 +2,11 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from brother import Brother, SnmpError, UnsupportedModelError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.components.snmp import async_get_snmp_engine from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_TYPE @@ -17,6 +16,9 @@ from .const import DOMAIN, PRINTER_TYPES +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DATA_SCHEMA = vol.Schema( { vol.Required(CONF_HOST): str, @@ -83,7 +85,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.host = discovery_info.host diff --git a/homeassistant/components/cambridge_audio/config_flow.py b/homeassistant/components/cambridge_audio/config_flow.py index 6f5a92feac05b..e29cb7efec4a7 100644 --- a/homeassistant/components/cambridge_audio/config_flow.py +++ b/homeassistant/components/cambridge_audio/config_flow.py @@ -1,12 +1,13 @@ """Config flow for Cambridge Audio.""" +from __future__ import annotations + import asyncio -from typing import Any +from typing import TYPE_CHECKING, Any from aiostreammagic import StreamMagicClient import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( SOURCE_RECONFIGURE, ConfigFlow, @@ -17,6 +18,9 @@ from .const import CONNECT_TIMEOUT, DOMAIN, STREAM_MAGIC_EXCEPTIONS +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str}) @@ -30,7 +34,7 @@ def __init__(self) -> None: self.data: dict[str, Any] = {} async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.data[CONF_HOST] = host = discovery_info.host diff --git a/homeassistant/components/daikin/config_flow.py b/homeassistant/components/daikin/config_flow.py index 5956d31c5fbbe..043813a2de2e6 100644 --- a/homeassistant/components/daikin/config_flow.py +++ b/homeassistant/components/daikin/config_flow.py @@ -4,7 +4,7 @@ import asyncio import logging -from typing import Any +from typing import TYPE_CHECKING, Any from uuid import uuid4 from aiohttp import ClientError, web_exceptions @@ -14,13 +14,15 @@ from pydaikin.factory import DaikinFactory import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_UUID from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN, KEY_MAC, TIMEOUT +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -142,7 +144,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a discovered Daikin device.""" _LOGGER.debug("Zeroconf user_input: %s", discovery_info) diff --git a/homeassistant/components/devialet/config_flow.py b/homeassistant/components/devialet/config_flow.py index 41acfa4b5a72e..88166060ee33c 100644 --- a/homeassistant/components/devialet/config_flow.py +++ b/homeassistant/components/devialet/config_flow.py @@ -3,18 +3,20 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from devialet.devialet_api import DevialetApi import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + LOGGER = logging.getLogger(__package__) @@ -70,7 +72,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" LOGGER.debug("Devialet device found via ZEROCONF: %s", discovery_info) diff --git a/homeassistant/components/dlink/config_flow.py b/homeassistant/components/dlink/config_flow.py index 4452a2958fc3c..50f2995ab7210 100644 --- a/homeassistant/components/dlink/config_flow.py +++ b/homeassistant/components/dlink/config_flow.py @@ -3,17 +3,19 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pyW215.pyW215 import SmartPlug import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from .const import CONF_USE_LEGACY_PROTOCOL, DEFAULT_NAME, DEFAULT_USERNAME, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -25,7 +27,7 @@ def __init__(self) -> None: self.ip_address: str | None = None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" await self.async_set_unique_id(discovery_info.macaddress) diff --git a/homeassistant/components/doorbird/config_flow.py b/homeassistant/components/doorbird/config_flow.py index ebb1d6fc12605..29a009e18f34c 100644 --- a/homeassistant/components/doorbird/config_flow.py +++ b/homeassistant/components/doorbird/config_flow.py @@ -5,13 +5,12 @@ from collections.abc import Mapping from http import HTTPStatus import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientResponseError from doorbirdpy import DoorBird import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -33,6 +32,9 @@ ) from .util import get_mac_address_from_door_station_info +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) DEFAULT_OPTIONS = {CONF_EVENTS: [DEFAULT_DOORBELL_EVENT, DEFAULT_MOTION_EVENT]} @@ -158,7 +160,7 @@ async def async_step_user( return self.async_show_form(step_id="user", data_schema=data, errors=errors) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a discovered doorbird device.""" macaddress = discovery_info.properties["macaddress"] diff --git a/homeassistant/components/eheimdigital/config_flow.py b/homeassistant/components/eheimdigital/config_flow.py index 6994c6f65b5aa..af3832d20efea 100644 --- a/homeassistant/components/eheimdigital/config_flow.py +++ b/homeassistant/components/eheimdigital/config_flow.py @@ -10,7 +10,6 @@ from eheimdigital.hub import EheimDigitalHub import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import SOURCE_USER, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.helpers import selector @@ -18,6 +17,9 @@ from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + CONFIG_SCHEMA = vol.Schema( {vol.Required(CONF_HOST, default="eheimdigital.local"): selector.TextSelector()} ) diff --git a/homeassistant/components/elgato/config_flow.py b/homeassistant/components/elgato/config_flow.py index e20afc73a2d8b..f6b10a6b40be4 100644 --- a/homeassistant/components/elgato/config_flow.py +++ b/homeassistant/components/elgato/config_flow.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from elgato import Elgato, ElgatoError import voluptuous as vol -from homeassistant.components import onboarding, zeroconf +from homeassistant.components import onboarding from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MAC from homeassistant.core import callback @@ -15,6 +15,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Elgato Light config flow.""" @@ -43,7 +46,7 @@ async def async_step_user( return self._async_create_entry() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.host = discovery_info.host diff --git a/homeassistant/components/elmax/config_flow.py b/homeassistant/components/elmax/config_flow.py index 09e0bc0d26074..5fc34c96aed16 100644 --- a/homeassistant/components/elmax/config_flow.py +++ b/homeassistant/components/elmax/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from elmax_api.exceptions import ElmaxBadLoginError, ElmaxBadPinError, ElmaxNetworkError from elmax_api.http import Elmax, ElmaxLocal, GenericElmax @@ -12,7 +12,6 @@ import httpx import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.exceptions import HomeAssistantError @@ -39,6 +38,9 @@ ELMAX_MODE_DIRECT_DEFAULT_HTTPS_PORT, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) LOGIN_FORM_SCHEMA = vol.Schema( diff --git a/homeassistant/components/emonitor/config_flow.py b/homeassistant/components/emonitor/config_flow.py index 833b80f9d47f8..f2a0f77c9fc51 100644 --- a/homeassistant/components/emonitor/config_flow.py +++ b/homeassistant/components/emonitor/config_flow.py @@ -1,13 +1,14 @@ """Config flow for SiteSage Emonitor integration.""" +from __future__ import annotations + import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aioemonitor import Emonitor import aiohttp import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant @@ -17,6 +18,9 @@ from . import name_short_mac from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -69,7 +73,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" self.discovered_ip = discovery_info.ip diff --git a/homeassistant/components/enphase_envoy/config_flow.py b/homeassistant/components/enphase_envoy/config_flow.py index 031d1883d1f01..4e18d0634b0cd 100644 --- a/homeassistant/components/enphase_envoy/config_flow.py +++ b/homeassistant/components/enphase_envoy/config_flow.py @@ -10,7 +10,6 @@ from pyenphase import AUTH_TOKEN_MIN_VERSION, Envoy, EnvoyError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( SOURCE_REAUTH, ConfigFlow, @@ -32,6 +31,9 @@ ) from .coordinator import EnphaseConfigEntry +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) ENVOY = "Envoy" @@ -123,7 +125,7 @@ def _async_current_hosts(self) -> set[str]: } async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" if _LOGGER.isEnabledFor(logging.DEBUG): diff --git a/homeassistant/components/esphome/config_flow.py b/homeassistant/components/esphome/config_flow.py index cb892b314cd06..f39572bcc1d34 100644 --- a/homeassistant/components/esphome/config_flow.py +++ b/homeassistant/components/esphome/config_flow.py @@ -6,7 +6,7 @@ from collections.abc import Mapping import json import logging -from typing import Any, cast +from typing import TYPE_CHECKING, Any, cast from aioesphomeapi import ( APIClient, @@ -20,7 +20,7 @@ import aiohttp import voluptuous as vol -from homeassistant.components import dhcp, zeroconf +from homeassistant.components import zeroconf from homeassistant.config_entries import ( SOURCE_REAUTH, ConfigEntry, @@ -45,6 +45,9 @@ ) from .dashboard import async_get_or_create_dashboard_manager, async_set_dashboard_info +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + ERROR_REQUIRES_ENCRYPTION_KEY = "requires_encryption_key" ERROR_INVALID_ENCRYPTION_KEY = "invalid_psk" ESPHOME_URL = "https://esphome.io/" @@ -293,7 +296,7 @@ async def async_step_mqtt( return await self.async_step_discovery_confirm() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle DHCP discovery.""" await self.async_set_unique_id(format_mac(discovery_info.macaddress)) diff --git a/homeassistant/components/flux_led/config_flow.py b/homeassistant/components/flux_led/config_flow.py index 9a02120f33ada..70b4b661a8e5f 100644 --- a/homeassistant/components/flux_led/config_flow.py +++ b/homeassistant/components/flux_led/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import contextlib -from typing import Any, Self, cast +from typing import TYPE_CHECKING, Any, Self, cast from flux_led.const import ( ATTR_ID, @@ -16,7 +16,6 @@ from flux_led.scanner import FluxLEDDiscovery import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ( SOURCE_IGNORE, ConfigEntry, @@ -55,6 +54,9 @@ ) from .util import format_as_flux_mac, mac_matches_by_one +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + class FluxLedConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Magic Home Integration.""" @@ -78,7 +80,7 @@ def async_get_options_flow( return FluxLedOptionsFlow() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" self._discovered_device = FluxLEDDiscovery( diff --git a/homeassistant/components/forked_daapd/config_flow.py b/homeassistant/components/forked_daapd/config_flow.py index 5fb9f08f1c009..f6352711868ea 100644 --- a/homeassistant/components/forked_daapd/config_flow.py +++ b/homeassistant/components/forked_daapd/config_flow.py @@ -1,13 +1,14 @@ """Config flow to configure forked-daapd devices.""" +from __future__ import annotations + from contextlib import suppress import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pyforked_daapd import ForkedDaapdAPI import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -29,6 +30,9 @@ DOMAIN, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -164,7 +168,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a discovered forked-daapd device.""" version_num = 0 diff --git a/homeassistant/components/freebox/config_flow.py b/homeassistant/components/freebox/config_flow.py index 88e2165defd78..93fd1e688b0e3 100644 --- a/homeassistant/components/freebox/config_flow.py +++ b/homeassistant/components/freebox/config_flow.py @@ -1,18 +1,22 @@ """Config flow to configure the Freebox integration.""" +from __future__ import annotations + import logging -from typing import Any +from typing import TYPE_CHECKING, Any from freebox_api.exceptions import AuthorizationError, HttpRequestError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from .const import DOMAIN from .router import get_api, get_hosts_list_if_supported +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -99,7 +103,7 @@ async def async_step_link( return self.async_show_form(step_id="link", errors=errors) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Initialize flow from zeroconf.""" zeroconf_properties = discovery_info.properties diff --git a/homeassistant/components/fronius/config_flow.py b/homeassistant/components/fronius/config_flow.py index ccc15d8040167..35d9fa78226d0 100644 --- a/homeassistant/components/fronius/config_flow.py +++ b/homeassistant/components/fronius/config_flow.py @@ -4,12 +4,11 @@ import asyncio import logging -from typing import Any, Final +from typing import TYPE_CHECKING, Any, Final from pyfronius import Fronius, FroniusError import voluptuous as vol -from homeassistant.components.dhcp import DhcpServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant @@ -18,6 +17,9 @@ from .const import DOMAIN, FroniusConfigEntryData +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER: Final = logging.getLogger(__name__) DHCP_REQUEST_DELAY: Final = 60 diff --git a/homeassistant/components/frontier_silicon/config_flow.py b/homeassistant/components/frontier_silicon/config_flow.py index 0612419fc335b..8eaadc727ec77 100644 --- a/homeassistant/components/frontier_silicon/config_flow.py +++ b/homeassistant/components/frontier_silicon/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urlparse from afsapi import ( @@ -15,7 +15,6 @@ ) import voluptuous as vol -from homeassistant.components import ssdp from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT @@ -27,6 +26,9 @@ SSDP_ATTR_SPEAKER_NAME, ) +if TYPE_CHECKING: + from homeassistant.components.ssdp import SsdpServiceInfo + _LOGGER = logging.getLogger(__name__) STEP_USER_DATA_SCHEMA = vol.Schema( @@ -87,7 +89,7 @@ async def async_step_user( ) async def async_step_ssdp( - self, discovery_info: ssdp.SsdpServiceInfo + self, discovery_info: SsdpServiceInfo ) -> ConfigFlowResult: """Process entity discovered via SSDP.""" diff --git a/homeassistant/components/fully_kiosk/config_flow.py b/homeassistant/components/fully_kiosk/config_flow.py index 15771d12b5dcc..59292e3d3205d 100644 --- a/homeassistant/components/fully_kiosk/config_flow.py +++ b/homeassistant/components/fully_kiosk/config_flow.py @@ -4,14 +4,13 @@ import asyncio import json -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp.client_exceptions import ClientConnectorError from fullykiosk import FullyKiosk from fullykiosk.exceptions import FullyKioskError import voluptuous as vol -from homeassistant.components.dhcp import DhcpServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_HOST, @@ -26,6 +25,9 @@ from .const import DEFAULT_PORT, DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + class FullyKioskConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Fully Kiosk Browser.""" diff --git a/homeassistant/components/goalzero/config_flow.py b/homeassistant/components/goalzero/config_flow.py index dabe642b6589f..af1a10514bb4f 100644 --- a/homeassistant/components/goalzero/config_flow.py +++ b/homeassistant/components/goalzero/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from goalzero import Yeti, exceptions import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -16,6 +15,9 @@ from .const import DEFAULT_NAME, DOMAIN, MANUFACTURER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -27,7 +29,7 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN): _discovered_ip: str async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" diff --git a/homeassistant/components/gogogate2/config_flow.py b/homeassistant/components/gogogate2/config_flow.py index 837c04547196f..82b27966015a4 100644 --- a/homeassistant/components/gogogate2/config_flow.py +++ b/homeassistant/components/gogogate2/config_flow.py @@ -4,13 +4,13 @@ import dataclasses import re -from typing import Any, Self +from typing import TYPE_CHECKING, Any, Self from ismartgate.common import AbstractInfoResponse, ApiError from ismartgate.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode import voluptuous as vol -from homeassistant.components import dhcp, zeroconf +from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_DEVICE, @@ -23,6 +23,9 @@ from .common import get_api from .const import DEVICE_TYPE_GOGOGATE2, DEVICE_TYPE_ISMARTGATE, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + DEVICE_NAMES = { DEVICE_TYPE_GOGOGATE2: "Gogogate2", DEVICE_TYPE_ISMARTGATE: "ismartgate", @@ -49,7 +52,7 @@ async def async_step_homekit( return await self._async_discovery_handler(discovery_info.host) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" await self.async_set_unique_id(discovery_info.macaddress) diff --git a/homeassistant/components/guardian/config_flow.py b/homeassistant/components/guardian/config_flow.py index c4146d72469b2..ff9aded8ea711 100644 --- a/homeassistant/components/guardian/config_flow.py +++ b/homeassistant/components/guardian/config_flow.py @@ -2,19 +2,22 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from aioguardian import Client from aioguardian.errors import GuardianError import voluptuous as vol -from homeassistant.components import dhcp, zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT from homeassistant.core import HomeAssistant, callback from .const import CONF_UID, DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DEFAULT_PORT = 7777 DATA_SCHEMA = vol.Schema( @@ -101,7 +104,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle the configuration via dhcp.""" self.discovery_info = { @@ -114,7 +117,7 @@ async def async_step_dhcp( return await self.async_step_discovery_confirm() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle the configuration via zeroconf.""" self.discovery_info = { diff --git a/homeassistant/components/homewizard/config_flow.py b/homeassistant/components/homewizard/config_flow.py index f88d1f1d7013a..3c820be3236dc 100644 --- a/homeassistant/components/homewizard/config_flow.py +++ b/homeassistant/components/homewizard/config_flow.py @@ -3,15 +3,14 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, NamedTuple +from typing import TYPE_CHECKING, Any, NamedTuple from homewizard_energy import HomeWizardEnergyV1 from homewizard_energy.errors import DisabledError, RequestError, UnsupportedError from homewizard_energy.models import Device import voluptuous as vol -from homeassistant.components import onboarding, zeroconf -from homeassistant.components.dhcp import DhcpServiceInfo +from homeassistant.components import onboarding from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_IP_ADDRESS, CONF_PATH from homeassistant.data_entry_flow import AbortFlow @@ -27,6 +26,10 @@ LOGGER, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class DiscoveryData(NamedTuple): """User metadata.""" @@ -79,7 +82,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" if ( diff --git a/homeassistant/components/hue/config_flow.py b/homeassistant/components/hue/config_flow.py index 8d17f81046154..0a440c244bed3 100644 --- a/homeassistant/components/hue/config_flow.py +++ b/homeassistant/components/hue/config_flow.py @@ -4,7 +4,7 @@ import asyncio import logging -from typing import Any +from typing import TYPE_CHECKING, Any import aiohttp from aiohue import LinkButtonNotPressed, create_app_key @@ -13,7 +13,6 @@ import slugify as unicode_slug import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -38,6 +37,9 @@ ) from .errors import CannotConnect +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + LOGGER = logging.getLogger(__name__) HUE_MANUFACTURERURL = ("http://www.philips.com", "http://www.philips-hue.com") @@ -214,7 +216,7 @@ async def async_step_link( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a discovered Hue bridge. @@ -243,7 +245,7 @@ async def async_step_zeroconf( return await self.async_step_link() async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a discovered Hue bridge on HomeKit. diff --git a/homeassistant/components/hunterdouglas_powerview/config_flow.py b/homeassistant/components/hunterdouglas_powerview/config_flow.py index debb9710dbdc9..74074bae0f010 100644 --- a/homeassistant/components/hunterdouglas_powerview/config_flow.py +++ b/homeassistant/components/hunterdouglas_powerview/config_flow.py @@ -7,7 +7,6 @@ import voluptuous as vol -from homeassistant.components import dhcp, zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_API_VERSION, CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant @@ -16,6 +15,10 @@ from .const import DOMAIN, HUB_EXCEPTIONS from .util import async_connect_hub +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) HAP_SUFFIX = "._hap._tcp.local." @@ -110,7 +113,7 @@ async def _async_validate_or_error( return info, None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle DHCP discovery.""" self.discovered_ip = discovery_info.ip @@ -118,7 +121,7 @@ async def async_step_dhcp( return await self.async_step_discovery_confirm() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.discovered_ip = discovery_info.host @@ -128,7 +131,7 @@ async def async_step_zeroconf( return await self.async_step_discovery_confirm() async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle HomeKit discovery.""" self.discovered_ip = discovery_info.host diff --git a/homeassistant/components/insteon/config_flow.py b/homeassistant/components/insteon/config_flow.py index 143a9e2a5e211..c3aae63d99d95 100644 --- a/homeassistant/components/insteon/config_flow.py +++ b/homeassistant/components/insteon/config_flow.py @@ -3,11 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pyinsteon import async_connect -from homeassistant.components import dhcp, usb +from homeassistant.components import usb from homeassistant.config_entries import ( DEFAULT_DISCOVERY_UNIQUE_ID, ConfigFlow, @@ -20,6 +20,9 @@ from .schemas import build_hub_schema, build_plm_manual_schema, build_plm_schema from .utils import async_get_usb_ports +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + STEP_PLM = "plm" STEP_PLM_MANUALLY = "plm_manually" STEP_HUB_V1 = "hubv1" @@ -162,7 +165,7 @@ async def async_step_confirm_usb( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle a DHCP discovery.""" self.discovered_conf = {CONF_HOST: discovery_info.ip} diff --git a/homeassistant/components/intellifire/config_flow.py b/homeassistant/components/intellifire/config_flow.py index a6b63f3b3e8ae..bc974c30030b2 100644 --- a/homeassistant/components/intellifire/config_flow.py +++ b/homeassistant/components/intellifire/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping from dataclasses import dataclass -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientConnectionError from intellifire4py.cloud_interface import IntelliFireCloudInterface @@ -13,7 +13,6 @@ from intellifire4py.model import IntelliFireCommonFireplaceData import voluptuous as vol -from homeassistant.components.dhcp import DhcpServiceInfo from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_API_KEY, @@ -35,6 +34,9 @@ LOGGER, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str}) MANUAL_ENTRY_STRING = "IP Address" # Simplified so it does not have to be translated diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index ecd4d1af9f6f5..d5ec4baca6c11 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pyipp import ( IPP, @@ -16,7 +16,6 @@ ) import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_HOST, @@ -31,6 +30,9 @@ from .const import CONF_BASE_PATH, CONF_SERIAL, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -103,7 +105,7 @@ async def async_step_user( return self.async_create_entry(title=user_input[CONF_HOST], data=user_input) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.host diff --git a/homeassistant/components/isy994/config_flow.py b/homeassistant/components/isy994/config_flow.py index 3575fa99a55e7..ce5c80c15b85d 100644 --- a/homeassistant/components/isy994/config_flow.py +++ b/homeassistant/components/isy994/config_flow.py @@ -5,7 +5,7 @@ import asyncio from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urlparse, urlunparse from aiohttp import CookieJar @@ -14,7 +14,7 @@ from pyisy.connection import Connection import voluptuous as vol -from homeassistant.components import dhcp, ssdp +from homeassistant.components import ssdp from homeassistant.config_entries import ( SOURCE_IGNORE, ConfigEntry, @@ -50,6 +50,9 @@ UDN_UUID_PREFIX, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -209,7 +212,7 @@ async def _async_set_unique_id_or_update( raise AbortFlow("already_configured") async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle a discovered ISY/IoX device via dhcp.""" friendly_name = discovery_info.hostname diff --git a/homeassistant/components/kodi/config_flow.py b/homeassistant/components/kodi/config_flow.py index f87b94b23fdea..f4f9fed023115 100644 --- a/homeassistant/components/kodi/config_flow.py +++ b/homeassistant/components/kodi/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pykodi import CannotConnectError, InvalidAuthError, Kodi, get_kodi_connection import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_HOST, @@ -32,6 +31,9 @@ DOMAIN, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -103,7 +105,7 @@ def __init__(self) -> None: self._discovery_name: str | None = None async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self._host = discovery_info.host diff --git a/homeassistant/components/lamarzocco/config_flow.py b/homeassistant/components/lamarzocco/config_flow.py index 70fb2c08b3400..507bdc14daffe 100644 --- a/homeassistant/components/lamarzocco/config_flow.py +++ b/homeassistant/components/lamarzocco/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientSession from pylamarzocco.clients.cloud import LaMarzoccoCloudClient @@ -17,7 +17,6 @@ BluetoothServiceInfo, async_discovered_service_info, ) -from homeassistant.components.dhcp import DhcpServiceInfo from homeassistant.config_entries import ( SOURCE_REAUTH, SOURCE_RECONFIGURE, @@ -51,6 +50,9 @@ from .const import CONF_USE_BLUETOOTH, DOMAIN from .coordinator import LaMarzoccoConfigEntry +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + CONF_MACHINE = "machine" _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/lametric/config_flow.py b/homeassistant/components/lametric/config_flow.py index 05c5dea77d1ae..6f50b1f252071 100644 --- a/homeassistant/components/lametric/config_flow.py +++ b/homeassistant/components/lametric/config_flow.py @@ -5,7 +5,7 @@ from collections.abc import Mapping from ipaddress import ip_address import logging -from typing import Any +from typing import TYPE_CHECKING, Any from demetriek import ( CloudDevice, @@ -23,7 +23,6 @@ import voluptuous as vol from yarl import URL -from homeassistant.components.dhcp import DhcpServiceInfo from homeassistant.components.ssdp import ( ATTR_UPNP_FRIENDLY_NAME, ATTR_UPNP_SERIAL, @@ -48,6 +47,9 @@ from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN): """Handle a LaMetric config flow.""" diff --git a/homeassistant/components/lektrico/config_flow.py b/homeassistant/components/lektrico/config_flow.py index 77f7b60853d3a..ca12763b426df 100644 --- a/homeassistant/components/lektrico/config_flow.py +++ b/homeassistant/components/lektrico/config_flow.py @@ -2,12 +2,11 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from lektricowifi import Device, DeviceConnectionError import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( ATTR_HW_VERSION, @@ -20,6 +19,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + STEP_USER_DATA_SCHEMA = vol.Schema( { vol.Required(CONF_HOST): str, diff --git a/homeassistant/components/lifx/config_flow.py b/homeassistant/components/lifx/config_flow.py index 053bb72c4fdd3..3b88c28b9387b 100644 --- a/homeassistant/components/lifx/config_flow.py +++ b/homeassistant/components/lifx/config_flow.py @@ -3,14 +3,12 @@ from __future__ import annotations import socket -from typing import Any, Self +from typing import TYPE_CHECKING, Any, Self from aiolifx.aiolifx import Light from aiolifx.connection import LIFXConnection import voluptuous as vol -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 @@ -35,6 +33,10 @@ mac_matches_serial_number, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class LifXConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for LIFX.""" @@ -72,7 +74,7 @@ async def async_step_dhcp( return await self._async_handle_discovery(host) async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle HomeKit discovery.""" return await self._async_handle_discovery(host=discovery_info.host) diff --git a/homeassistant/components/linkplay/config_flow.py b/homeassistant/components/linkplay/config_flow.py index 7dfdce238ff20..68f21ee6ad3b5 100644 --- a/homeassistant/components/linkplay/config_flow.py +++ b/homeassistant/components/linkplay/config_flow.py @@ -1,7 +1,9 @@ """Config flow to configure LinkPlay component.""" +from __future__ import annotations + import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientSession from linkplay.bridge import LinkPlayBridge @@ -9,13 +11,15 @@ from linkplay.exceptions import LinkPlayRequestException import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MODEL from .const import DOMAIN from .utils import async_get_client_session +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -27,7 +31,7 @@ def __init__(self) -> None: self.data: dict[str, Any] = {} async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle Zeroconf discovery.""" diff --git a/homeassistant/components/lookin/config_flow.py b/homeassistant/components/lookin/config_flow.py index aaf98a06fa85c..2f80b8256e0a5 100644 --- a/homeassistant/components/lookin/config_flow.py +++ b/homeassistant/components/lookin/config_flow.py @@ -3,19 +3,21 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any import aiohttp from aiolookin import Device, LookInHttpProtocol, NoUsableService import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + LOGGER = logging.getLogger(__name__) @@ -28,7 +30,7 @@ def __init__(self) -> None: self._name: str | None = None async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Start a discovery flow from zeroconf.""" uid: str = discovery_info.hostname.removesuffix(".local.") diff --git a/homeassistant/components/loqed/config_flow.py b/homeassistant/components/loqed/config_flow.py index 8c82a7a69647f..4d77c8efb9670 100644 --- a/homeassistant/components/loqed/config_flow.py +++ b/homeassistant/components/loqed/config_flow.py @@ -4,14 +4,13 @@ import logging import re -from typing import Any +from typing import TYPE_CHECKING, Any import aiohttp from loqedAPI import cloud_loqed, loqed import voluptuous as vol 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 @@ -20,6 +19,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/lutron_caseta/config_flow.py b/homeassistant/components/lutron_caseta/config_flow.py index cd566b767fb0e..e3426af483a68 100644 --- a/homeassistant/components/lutron_caseta/config_flow.py +++ b/homeassistant/components/lutron_caseta/config_flow.py @@ -6,13 +6,12 @@ import logging import os import ssl -from typing import Any +from typing import TYPE_CHECKING, Any 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.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.core import callback @@ -29,6 +28,9 @@ STEP_IMPORT_FAILED, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + HOSTNAME = "hostname" @@ -69,7 +71,7 @@ async def async_step_user( return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA_USER) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" hostname = discovery_info.hostname @@ -90,7 +92,7 @@ async def async_step_zeroconf( return await self.async_step_link() async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by homekit discovery.""" return await self.async_step_zeroconf(discovery_info) diff --git a/homeassistant/components/matter/config_flow.py b/homeassistant/components/matter/config_flow.py index 6f7505eb61ff4..aa65b769da514 100644 --- a/homeassistant/components/matter/config_flow.py +++ b/homeassistant/components/matter/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio -from typing import Any +from typing import TYPE_CHECKING, Any from matter_server.client import MatterClient from matter_server.client.exceptions import CannotConnect, InvalidServerVersion @@ -16,7 +16,6 @@ AddonState, ) from homeassistant.components.onboarding import async_is_onboarded -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_URL from homeassistant.core import HomeAssistant @@ -35,6 +34,9 @@ LOGGER, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + ADDON_SETUP_TIMEOUT = 5 ADDON_SETUP_TIMEOUT_ROUNDS = 40 DEFAULT_URL = "ws://localhost:5580/ws" diff --git a/homeassistant/components/modern_forms/config_flow.py b/homeassistant/components/modern_forms/config_flow.py index 3c217b5747f0b..06c4d08024430 100644 --- a/homeassistant/components/modern_forms/config_flow.py +++ b/homeassistant/components/modern_forms/config_flow.py @@ -2,18 +2,20 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from aiomodernforms import ModernFormsConnectionError, ModernFormsDevice import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MAC from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + USER_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str}) @@ -39,7 +41,7 @@ async def async_step_user( return await self._handle_config_flow() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.hostname.rstrip(".") diff --git a/homeassistant/components/motion_blinds/config_flow.py b/homeassistant/components/motion_blinds/config_flow.py index e961880375c39..0a769d1c4d0d4 100644 --- a/homeassistant/components/motion_blinds/config_flow.py +++ b/homeassistant/components/motion_blinds/config_flow.py @@ -2,12 +2,11 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from motionblinds import MotionDiscovery, MotionGateway import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -28,6 +27,9 @@ ) from .gateway import ConnectMotionGateway +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + CONFIG_SCHEMA = vol.Schema( { vol.Optional(CONF_HOST): str, @@ -82,7 +84,7 @@ def async_get_options_flow( return OptionsFlowHandler() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" mac_address = format_mac(discovery_info.macaddress).replace(":", "") diff --git a/homeassistant/components/motionmount/config_flow.py b/homeassistant/components/motionmount/config_flow.py index 19d3557d36b48..b1c626f1b20f1 100644 --- a/homeassistant/components/motionmount/config_flow.py +++ b/homeassistant/components/motionmount/config_flow.py @@ -1,13 +1,14 @@ """Config flow for Vogel's MotionMount.""" +from __future__ import annotations + import logging import socket -from typing import Any +from typing import TYPE_CHECKING, Any import motionmount import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( DEFAULT_DISCOVERY_UNIQUE_ID, ConfigFlow, @@ -18,6 +19,9 @@ from .const import DOMAIN, EMPTY_MAC +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -80,7 +84,7 @@ async def async_step_user( return self.async_create_entry(title=name, data=user_input) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" diff --git a/homeassistant/components/music_assistant/config_flow.py b/homeassistant/components/music_assistant/config_flow.py index fc50a2d654bf7..6fe88abc1f094 100644 --- a/homeassistant/components/music_assistant/config_flow.py +++ b/homeassistant/components/music_assistant/config_flow.py @@ -13,7 +13,6 @@ from music_assistant_models.api import ServerInfoMessage import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_URL from homeassistant.core import HomeAssistant @@ -21,6 +20,9 @@ from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DEFAULT_URL = "http://mass.local:8095" DEFAULT_TITLE = "Music Assistant" @@ -93,7 +95,7 @@ async def async_step_user( return self.async_show_form(step_id="user", data_schema=get_manual_schema({})) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a discovered Mass server. diff --git a/homeassistant/components/nam/config_flow.py b/homeassistant/components/nam/config_flow.py index 494ce9fdac03d..3d84d0941c48d 100644 --- a/homeassistant/components/nam/config_flow.py +++ b/homeassistant/components/nam/config_flow.py @@ -5,7 +5,7 @@ from collections.abc import Mapping from dataclasses import dataclass import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp.client_exceptions import ClientConnectorError from nettigo_air_monitor import ( @@ -17,7 +17,6 @@ ) import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant @@ -26,6 +25,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + @dataclass class NamConfig: @@ -138,7 +140,7 @@ async def async_step_credentials( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.host = discovery_info.host diff --git a/homeassistant/components/nanoleaf/config_flow.py b/homeassistant/components/nanoleaf/config_flow.py index 27ef9a887feb2..bfd21584dfd01 100644 --- a/homeassistant/components/nanoleaf/config_flow.py +++ b/homeassistant/components/nanoleaf/config_flow.py @@ -5,12 +5,12 @@ from collections.abc import Mapping import logging import os -from typing import Any, Final, cast +from typing import TYPE_CHECKING, Any, Final, cast from aionanoleaf import InvalidToken, Nanoleaf, Unauthorized, Unavailable import voluptuous as vol -from homeassistant.components import ssdp, zeroconf +from homeassistant.components import zeroconf from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_TOKEN from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -19,6 +19,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.ssdp import SsdpServiceInfo + _LOGGER = logging.getLogger(__name__) # For discovery integration import @@ -110,7 +113,7 @@ async def _async_homekit_zeroconf_discovery_handler( ) async def async_step_ssdp( - self, discovery_info: ssdp.SsdpServiceInfo + self, discovery_info: SsdpServiceInfo ) -> ConfigFlowResult: """Handle Nanoleaf SSDP discovery.""" _LOGGER.debug("SSDP discovered: %s", discovery_info) diff --git a/homeassistant/components/nuki/config_flow.py b/homeassistant/components/nuki/config_flow.py index 4a9789c7e5134..51c4fcf968731 100644 --- a/homeassistant/components/nuki/config_flow.py +++ b/homeassistant/components/nuki/config_flow.py @@ -1,15 +1,16 @@ """Config flow to configure the Nuki integration.""" +from __future__ import annotations + from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pynuki import NukiBridge from pynuki.bridge import InvalidCredentialsException from requests.exceptions import RequestException import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN from homeassistant.core import HomeAssistant @@ -17,6 +18,9 @@ from .const import CONF_ENCRYPT_TOKEN, DEFAULT_PORT, DEFAULT_TIMEOUT, DOMAIN from .helpers import CannotConnect, InvalidAuth, parse_id +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) USER_SCHEMA = vol.Schema( @@ -75,7 +79,7 @@ async def async_step_user( return await self.async_step_validate(user_input) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a DHCP discovered Nuki bridge.""" await self.async_set_unique_id(discovery_info.hostname[12:].upper()) diff --git a/homeassistant/components/nut/config_flow.py b/homeassistant/components/nut/config_flow.py index 966c51e98e9d0..39ca5efd44856 100644 --- a/homeassistant/components/nut/config_flow.py +++ b/homeassistant/components/nut/config_flow.py @@ -4,12 +4,11 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aionut import NUTError, NUTLoginError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -31,6 +30,9 @@ from . import PyNUTData from .const import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) AUTH_SCHEMA = {vol.Optional(CONF_USERNAME): str, vol.Optional(CONF_PASSWORD): str} @@ -95,7 +97,7 @@ def __init__(self) -> None: self.reauth_entry: ConfigEntry | None = None async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a discovered nut device.""" await self._async_handle_discovery_without_unique_id() diff --git a/homeassistant/components/obihai/config_flow.py b/homeassistant/components/obihai/config_flow.py index 559900db5d0f7..485f7a375b3bd 100644 --- a/homeassistant/components/obihai/config_flow.py +++ b/homeassistant/components/obihai/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations from socket import gaierror, gethostbyname -from typing import Any +from typing import TYPE_CHECKING, Any from pyobihai import PyObihai import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant @@ -17,6 +16,9 @@ from .connectivity import validate_auth from .const import DEFAULT_PASSWORD, DEFAULT_USERNAME, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + DATA_SCHEMA = vol.Schema( { vol.Required(CONF_HOST): str, @@ -54,7 +56,7 @@ class ObihaiFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 2 discovery_schema: vol.Schema | None = None - _dhcp_discovery_info: dhcp.DhcpServiceInfo | None = None + _dhcp_discovery_info: DhcpServiceInfo | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None @@ -94,7 +96,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a DHCP discovered Obihai.""" diff --git a/homeassistant/components/octoprint/config_flow.py b/homeassistant/components/octoprint/config_flow.py index 9bbf21d71fa46..4cc7ad756dc47 100644 --- a/homeassistant/components/octoprint/config_flow.py +++ b/homeassistant/components/octoprint/config_flow.py @@ -12,7 +12,6 @@ import voluptuous as vol from yarl import URL -from homeassistant.components import ssdp, zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import ( CONF_API_KEY, @@ -30,6 +29,10 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.ssdp import SsdpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -167,7 +170,7 @@ async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResu return await self.async_step_user(import_data) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle discovery flow.""" uuid = discovery_info.properties["uuid"] @@ -193,7 +196,7 @@ async def async_step_zeroconf( return await self.async_step_user() async def async_step_ssdp( - self, discovery_info: ssdp.SsdpServiceInfo + self, discovery_info: SsdpServiceInfo ) -> ConfigFlowResult: """Handle ssdp discovery flow.""" uuid = discovery_info.upnp["UDN"][5:] diff --git a/homeassistant/components/onkyo/config_flow.py b/homeassistant/components/onkyo/config_flow.py index a484b3aaa049d..ad08cd9bd3106 100644 --- a/homeassistant/components/onkyo/config_flow.py +++ b/homeassistant/components/onkyo/config_flow.py @@ -1,12 +1,13 @@ """Config flow for Onkyo.""" +from __future__ import annotations + import logging -from typing import Any +from typing import TYPE_CHECKING, Any import voluptuous as vol from yarl import URL -from homeassistant.components import ssdp from homeassistant.config_entries import ( SOURCE_RECONFIGURE, ConfigEntry, @@ -41,6 +42,9 @@ ) from .receiver import ReceiverInfo, async_discover, async_interview +if TYPE_CHECKING: + from homeassistant.components.ssdp import SsdpServiceInfo + _LOGGER = logging.getLogger(__name__) CONF_DEVICE = "device" @@ -168,7 +172,7 @@ async def async_step_eiscp_discovery( ) async def async_step_ssdp( - self, discovery_info: ssdp.SsdpServiceInfo + self, discovery_info: SsdpServiceInfo ) -> ConfigFlowResult: """Handle flow initialized by SSDP discovery.""" _LOGGER.debug("Config flow start ssdp: %s", discovery_info) diff --git a/homeassistant/components/onvif/config_flow.py b/homeassistant/components/onvif/config_flow.py index 66e566af0bf90..f4543c28253b1 100644 --- a/homeassistant/components/onvif/config_flow.py +++ b/homeassistant/components/onvif/config_flow.py @@ -5,7 +5,7 @@ from collections.abc import Mapping import logging from pprint import pformat -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urlparse from onvif.util import is_auth_error, stringify_onvif_error @@ -15,7 +15,6 @@ from wsdiscovery.service import Service from zeep.exceptions import Fault -from homeassistant.components import dhcp from homeassistant.components.ffmpeg import CONF_EXTRA_ARGUMENTS from homeassistant.components.stream import ( CONF_RTSP_TRANSPORT, @@ -53,6 +52,9 @@ ) from .device import get_device +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + CONF_MANUAL_INPUT = "Manually configure ONVIF device" @@ -170,7 +172,7 @@ async def async_step_reauth_confirm( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" hass = self.hass diff --git a/homeassistant/components/palazzetti/config_flow.py b/homeassistant/components/palazzetti/config_flow.py index fe892b6624dd7..474cf17602235 100644 --- a/homeassistant/components/palazzetti/config_flow.py +++ b/homeassistant/components/palazzetti/config_flow.py @@ -1,18 +1,22 @@ """Config flow for Palazzetti.""" -from typing import Any +from __future__ import annotations + +from typing import TYPE_CHECKING, Any from pypalazzetti.client import PalazzettiClient from pypalazzetti.exceptions import CommunicationError import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.helpers import device_registry as dr from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + class PalazzettiConfigFlow(ConfigFlow, domain=DOMAIN): """Palazzetti config flow.""" @@ -53,7 +57,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle DHCP discovery.""" diff --git a/homeassistant/components/peblar/config_flow.py b/homeassistant/components/peblar/config_flow.py index 24248355f722c..3640927b9125f 100644 --- a/homeassistant/components/peblar/config_flow.py +++ b/homeassistant/components/peblar/config_flow.py @@ -3,13 +3,12 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import CookieJar from peblar import Peblar, PeblarAuthenticationError, PeblarConnectionError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.helpers.aiohttp_client import async_create_clientsession @@ -21,13 +20,16 @@ from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class PeblarFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Peblar config flow.""" VERSION = 1 - _discovery_info: zeroconf.ZeroconfServiceInfo + _discovery_info: ZeroconfServiceInfo async def async_step_user( self, user_input: dict[str, Any] | None = None @@ -128,7 +130,7 @@ async def async_step_reconfigure( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery of a Peblar device.""" if not (sn := discovery_info.properties.get("sn")): diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 6114dd39a6de7..0fce046701f20 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import logging -from typing import Any, Self +from typing import TYPE_CHECKING, Any, Self from plugwise import Smile from plugwise.exceptions import ( @@ -16,7 +16,6 @@ ) import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import SOURCE_USER, ConfigFlow, ConfigFlowResult from homeassistant.const import ( ATTR_CONFIGURATION_URL, @@ -42,6 +41,9 @@ ZEROCONF_MAP, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) SMILE_RECONF_SCHEMA = vol.Schema( diff --git a/homeassistant/components/pure_energie/config_flow.py b/homeassistant/components/pure_energie/config_flow.py index a2bbb671ff7eb..179b1d2fbf5cb 100644 --- a/homeassistant/components/pure_energie/config_flow.py +++ b/homeassistant/components/pure_energie/config_flow.py @@ -2,12 +2,11 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from gridnet import Device, GridNet, GridNetConnectionError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -15,6 +14,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class PureEnergieFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Pure Energie integration.""" @@ -58,7 +60,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.discovered_host = discovery_info.host diff --git a/homeassistant/components/qnap_qsw/config_flow.py b/homeassistant/components/qnap_qsw/config_flow.py index 3a10e54ac82fb..6b4d99a902211 100644 --- a/homeassistant/components/qnap_qsw/config_flow.py +++ b/homeassistant/components/qnap_qsw/config_flow.py @@ -3,13 +3,12 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aioqsw.exceptions import LoginError, QswError from aioqsw.localapi import ConnectionOptions, QnapQswApi import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME from homeassistant.data_entry_flow import AbortFlow @@ -18,6 +17,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -73,7 +75,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle DHCP discovery.""" self._discovered_url = f"http://{discovery_info.ip}" diff --git a/homeassistant/components/radiotherm/config_flow.py b/homeassistant/components/radiotherm/config_flow.py index e29c4703e0877..4ff6809012f7c 100644 --- a/homeassistant/components/radiotherm/config_flow.py +++ b/homeassistant/components/radiotherm/config_flow.py @@ -3,13 +3,12 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.error import URLError from radiotherm.validate import RadiothermTstatError import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant @@ -18,6 +17,9 @@ from .const import DOMAIN from .data import RadioThermInitData, async_get_init_data +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -44,7 +46,7 @@ def __init__(self) -> None: self.discovered_init_data: RadioThermInitData | None = None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Discover via DHCP.""" self._async_abort_entries_match({CONF_HOST: discovery_info.ip}) diff --git a/homeassistant/components/rainmachine/config_flow.py b/homeassistant/components/rainmachine/config_flow.py index 0b40d50656623..5635edd240489 100644 --- a/homeassistant/components/rainmachine/config_flow.py +++ b/homeassistant/components/rainmachine/config_flow.py @@ -2,14 +2,13 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from regenmaschine import Client from regenmaschine.controller import Controller from regenmaschine.errors import RainMachineError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -29,6 +28,9 @@ DOMAIN, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + @callback def get_client_controller(client: Client) -> Controller: @@ -66,19 +68,19 @@ def async_get_options_flow( return RainMachineOptionsFlowHandler() async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by homekit discovery.""" return await self.async_step_homekit_zeroconf(discovery_info) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle discovery via zeroconf.""" return await self.async_step_homekit_zeroconf(discovery_info) async def async_step_homekit_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle discovery via zeroconf.""" ip_address = discovery_info.host diff --git a/homeassistant/components/reolink/config_flow.py b/homeassistant/components/reolink/config_flow.py index c28e076aab4e7..14738d3846583 100644 --- a/homeassistant/components/reolink/config_flow.py +++ b/homeassistant/components/reolink/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from reolink_aio.api import ALLOWED_SPECIAL_CHARS from reolink_aio.exceptions import ( @@ -15,7 +15,6 @@ ) import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ( SOURCE_REAUTH, SOURCE_RECONFIGURE, @@ -45,6 +44,9 @@ from .host import ReolinkHost from .util import ReolinkConfigEntry, is_connected +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) DEFAULT_PROTOCOL = "rtsp" @@ -142,7 +144,7 @@ async def async_step_reconfigure( return await self.async_step_user() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" mac_address = format_mac(discovery_info.macaddress) diff --git a/homeassistant/components/roku/config_flow.py b/homeassistant/components/roku/config_flow.py index bc0092d695385..aefa26ebc3091 100644 --- a/homeassistant/components/roku/config_flow.py +++ b/homeassistant/components/roku/config_flow.py @@ -3,13 +3,13 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urlparse from rokuecp import Roku, RokuError import voluptuous as vol -from homeassistant.components import ssdp, zeroconf +from homeassistant.components import ssdp from homeassistant.config_entries import ( SOURCE_RECONFIGURE, ConfigFlow, @@ -23,6 +23,9 @@ from . import RokuConfigEntry from .const import CONF_PLAY_MEDIA_APP_ID, DEFAULT_PLAY_MEDIA_APP_ID, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str}) ERROR_CANNOT_CONNECT = "cannot_connect" @@ -117,7 +120,7 @@ async def async_step_user( return self.async_create_entry(title=info["title"], data=user_input) async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by homekit discovery.""" diff --git a/homeassistant/components/romy/config_flow.py b/homeassistant/components/romy/config_flow.py index e571ff41c9a8d..e3ec510b4d04e 100644 --- a/homeassistant/components/romy/config_flow.py +++ b/homeassistant/components/romy/config_flow.py @@ -2,16 +2,20 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import romy import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD import homeassistant.helpers.config_validation as cv from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class RomyConfigFlow(ConfigFlow, domain=DOMAIN): """Handle config flow for ROMY.""" @@ -84,7 +88,7 @@ async def async_step_password( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" diff --git a/homeassistant/components/roomba/config_flow.py b/homeassistant/components/roomba/config_flow.py index d040074246adf..3780e09e35fbf 100644 --- a/homeassistant/components/roomba/config_flow.py +++ b/homeassistant/components/roomba/config_flow.py @@ -4,14 +4,13 @@ import asyncio from functools import partial -from typing import Any +from typing import TYPE_CHECKING, Any from roombapy import RoombaFactory, RoombaInfo from roombapy.discovery import RoombaDiscovery from roombapy.getpassword import RoombaPassword import voluptuous as vol -from homeassistant.components import dhcp, zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -31,6 +30,10 @@ ROOMBA_SESSION, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + ROOMBA_DISCOVERY_LOCK = "roomba_discovery_lock" ALL_ATTEMPTS = 2 HOST_ATTEMPTS = 6 @@ -95,7 +98,7 @@ def async_get_options_flow( return RoombaOptionsFlowHandler() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" return await self._async_step_discovery( @@ -103,7 +106,7 @@ async def async_step_zeroconf( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" return await self._async_step_discovery( diff --git a/homeassistant/components/russound_rio/config_flow.py b/homeassistant/components/russound_rio/config_flow.py index 5618a424726b1..493d7a092e8ba 100644 --- a/homeassistant/components/russound_rio/config_flow.py +++ b/homeassistant/components/russound_rio/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiorussound import RussoundClient, RussoundTcpConnectionHandler import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( SOURCE_RECONFIGURE, ConfigFlow, @@ -19,6 +18,9 @@ from .const import DOMAIN, RUSSOUND_RIO_EXCEPTIONS +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DATA_SCHEMA = vol.Schema( { vol.Required(CONF_HOST): cv.string, @@ -39,7 +41,7 @@ def __init__(self) -> None: self.data: dict[str, Any] = {} async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self.data[CONF_HOST] = host = discovery_info.host diff --git a/homeassistant/components/ruuvi_gateway/config_flow.py b/homeassistant/components/ruuvi_gateway/config_flow.py index c22f100e87acc..0333338ba0ed5 100644 --- a/homeassistant/components/ruuvi_gateway/config_flow.py +++ b/homeassistant/components/ruuvi_gateway/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any import aioruuvigateway.api as gw_api from aioruuvigateway.excs import CannotConnect, InvalidAuth -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_TOKEN from homeassistant.helpers.device_registry import format_mac @@ -17,6 +16,9 @@ from . import DOMAIN from .schemata import CONFIG_SCHEMA, get_config_schema_with_default_host +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -82,7 +84,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Prepare configuration for a DHCP discovered Ruuvi Gateway.""" await self.async_set_unique_id(format_mac(discovery_info.macaddress)) diff --git a/homeassistant/components/samsungtv/config_flow.py b/homeassistant/components/samsungtv/config_flow.py index b3dabca1df43f..0f84af0eb9c61 100644 --- a/homeassistant/components/samsungtv/config_flow.py +++ b/homeassistant/components/samsungtv/config_flow.py @@ -5,14 +5,14 @@ from collections.abc import Mapping from functools import partial import socket -from typing import Any, Self +from typing import TYPE_CHECKING, Any, Self from urllib.parse import urlparse import getmac from samsungtvws.encrypted.authenticator import SamsungTVEncryptedWSAsyncAuthenticator import voluptuous as vol -from homeassistant.components import dhcp, ssdp, zeroconf +from homeassistant.components import ssdp from homeassistant.config_entries import ( ConfigEntry, ConfigEntryState, @@ -55,6 +55,10 @@ UPNP_SVC_RENDERING_CONTROL, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str, vol.Required(CONF_NAME): str}) @@ -486,7 +490,7 @@ async def async_step_ssdp( return await self.async_step_confirm() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by dhcp discovery.""" LOGGER.debug("Samsung device found via DHCP: %s", discovery_info) @@ -498,7 +502,7 @@ async def async_step_dhcp( return await self.async_step_confirm() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf discovery.""" LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info) diff --git a/homeassistant/components/screenlogic/config_flow.py b/homeassistant/components/screenlogic/config_flow.py index 19db89dc03de8..b3aa58d8625a1 100644 --- a/homeassistant/components/screenlogic/config_flow.py +++ b/homeassistant/components/screenlogic/config_flow.py @@ -3,14 +3,13 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from screenlogicpy import ScreenLogicError, discovery from screenlogicpy.const.common import SL_GATEWAY_IP, SL_GATEWAY_NAME, SL_GATEWAY_PORT from screenlogicpy.requests import login import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -24,6 +23,9 @@ from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, MIN_SCAN_INTERVAL +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) GATEWAY_SELECT_KEY = "selected_gateway" @@ -91,7 +93,7 @@ async def async_step_user( return await self.async_step_gateway_select() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" mac = format_mac(discovery_info.macaddress) diff --git a/homeassistant/components/shelly/config_flow.py b/homeassistant/components/shelly/config_flow.py index 55686464637da..636f1e248dc45 100644 --- a/homeassistant/components/shelly/config_flow.py +++ b/homeassistant/components/shelly/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, Final +from typing import TYPE_CHECKING, Any, Final from aioshelly.block_device import BlockDevice from aioshelly.common import ConnectionOptions, get_info @@ -17,7 +17,6 @@ from aioshelly.rpc_device import RpcDevice import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -58,6 +57,9 @@ mac_address_from_name, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + CONFIG_SCHEMA: Final = vol.Schema( { vol.Required(CONF_HOST): str, diff --git a/homeassistant/components/slide_local/config_flow.py b/homeassistant/components/slide_local/config_flow.py index a4255f0769f7c..72090598cc810 100644 --- a/homeassistant/components/slide_local/config_flow.py +++ b/homeassistant/components/slide_local/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from goslideapi.goslideapi import ( AuthenticationFailed, @@ -14,7 +14,6 @@ ) import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow from homeassistant.const import CONF_API_VERSION, CONF_HOST, CONF_MAC, CONF_PASSWORD from homeassistant.core import callback @@ -23,6 +22,9 @@ from . import SlideConfigEntry from .const import CONF_INVERT_POSITION, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/smappee/config_flow.py b/homeassistant/components/smappee/config_flow.py index 4f7a71218abbb..d4de0186deeb4 100644 --- a/homeassistant/components/smappee/config_flow.py +++ b/homeassistant/components/smappee/config_flow.py @@ -1,12 +1,13 @@ """Config flow for Smappee.""" +from __future__ import annotations + import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pysmappee import helper, mqtt import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS from homeassistant.helpers import config_entry_oauth2_flow @@ -20,6 +21,9 @@ SUPPORTED_LOCAL_DEVICES, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class SmappeeFlowHandler( config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN @@ -43,7 +47,7 @@ def logger(self) -> logging.Logger: return logging.getLogger(__name__) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" diff --git a/homeassistant/components/smlight/config_flow.py b/homeassistant/components/smlight/config_flow.py index 92b543e04410c..dfc36c4b05da2 100644 --- a/homeassistant/components/smlight/config_flow.py +++ b/homeassistant/components/smlight/config_flow.py @@ -3,13 +3,12 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any +from typing import TYPE_CHECKING, Any from pysmlight import Api2 from pysmlight.exceptions import SmlightAuthError, SmlightConnectionError import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -17,6 +16,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + STEP_USER_DATA_SCHEMA = vol.Schema( { vol.Required(CONF_HOST): str, @@ -82,7 +84,7 @@ async def async_step_auth( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a discovered Lan coordinator.""" local_name = discovery_info.hostname[:-1] diff --git a/homeassistant/components/somfy_mylink/config_flow.py b/homeassistant/components/somfy_mylink/config_flow.py index c2d851601750b..81119f66f85d0 100644 --- a/homeassistant/components/somfy_mylink/config_flow.py +++ b/homeassistant/components/somfy_mylink/config_flow.py @@ -4,12 +4,11 @@ from copy import deepcopy import logging -from typing import Any +from typing import TYPE_CHECKING, Any from somfy_mylink_synergy import SomfyMyLinkSynergy import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ( ConfigEntry, ConfigEntryState, @@ -33,6 +32,9 @@ MYLINK_STATUS, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -69,7 +71,7 @@ def __init__(self) -> None: self.ip_address: str | None = None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" self._async_abort_entries_match({CONF_HOST: discovery_info.ip}) diff --git a/homeassistant/components/sonos/config_flow.py b/homeassistant/components/sonos/config_flow.py index a8ace6e35c56d..db69d4d603506 100644 --- a/homeassistant/components/sonos/config_flow.py +++ b/homeassistant/components/sonos/config_flow.py @@ -1,9 +1,12 @@ """Config flow for SONOS.""" +from __future__ import annotations + from collections.abc import Awaitable import dataclasses +from typing import TYPE_CHECKING -from homeassistant.components import ssdp, zeroconf +from homeassistant.components import ssdp from homeassistant.config_entries import ConfigFlowResult from homeassistant.core import HomeAssistant from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler @@ -11,6 +14,9 @@ from .const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN, UPNP_ST from .helpers import hostname_to_uid +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + async def _async_has_devices(hass: HomeAssistant) -> bool: """Return if Sonos devices have been seen recently with SSDP.""" @@ -25,7 +31,7 @@ def __init__(self) -> None: super().__init__(DOMAIN, "Sonos", _async_has_devices) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by zeroconf.""" hostname = discovery_info.hostname diff --git a/homeassistant/components/soundtouch/config_flow.py b/homeassistant/components/soundtouch/config_flow.py index af45b8f6bdc75..7531bf3aad5bb 100644 --- a/homeassistant/components/soundtouch/config_flow.py +++ b/homeassistant/components/soundtouch/config_flow.py @@ -1,18 +1,22 @@ """Config flow for Bose SoundTouch integration.""" -from typing import Any +from __future__ import annotations + +from typing import TYPE_CHECKING, Any from libsoundtouch import soundtouch_device from requests import RequestException import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.helpers import config_validation as cv from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class SoundtouchConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for Bose SoundTouch.""" diff --git a/homeassistant/components/squeezebox/config_flow.py b/homeassistant/components/squeezebox/config_flow.py index c372c7262d456..f5cd053ed5ee9 100644 --- a/homeassistant/components/squeezebox/config_flow.py +++ b/homeassistant/components/squeezebox/config_flow.py @@ -10,7 +10,6 @@ from pysqueezebox import Server, async_discover import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.components.media_player import DOMAIN as MP_DOMAIN from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME @@ -21,6 +20,9 @@ from .const import CONF_HTTPS, DEFAULT_PORT, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) TIMEOUT = 5 @@ -200,7 +202,7 @@ async def async_step_integration_discovery( return await self.async_step_edit() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery of a Squeezebox player.""" _LOGGER.debug( diff --git a/homeassistant/components/steamist/config_flow.py b/homeassistant/components/steamist/config_flow.py index f22eafc6afdf9..92fa563d50a88 100644 --- a/homeassistant/components/steamist/config_flow.py +++ b/homeassistant/components/steamist/config_flow.py @@ -3,13 +3,12 @@ from __future__ import annotations import logging -from typing import Any, Self +from typing import TYPE_CHECKING, Any, Self from aiosteamist import Steamist from discovery30303 import Device30303, normalize_mac import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MODEL, CONF_NAME from homeassistant.core import callback @@ -25,6 +24,9 @@ async_update_entry_from_discovery, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -41,7 +43,7 @@ def __init__(self) -> None: self._discovered_device: Device30303 | None = None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" self._discovered_device = Device30303( diff --git a/homeassistant/components/system_bridge/config_flow.py b/homeassistant/components/system_bridge/config_flow.py index 98396e52545b1..704af05dac83e 100644 --- a/homeassistant/components/system_bridge/config_flow.py +++ b/homeassistant/components/system_bridge/config_flow.py @@ -5,7 +5,7 @@ import asyncio from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from systembridgeconnector.exceptions import ( AuthenticationException, @@ -16,7 +16,6 @@ from systembridgemodels.modules import GetData, Module import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN from homeassistant.core import HomeAssistant @@ -26,6 +25,9 @@ from .const import DATA_WAIT_TIMEOUT, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) STEP_AUTHENTICATE_DATA_SCHEMA = vol.Schema({vol.Required(CONF_TOKEN): cv.string}) @@ -179,7 +181,7 @@ async def async_step_authenticate( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" properties = discovery_info.properties diff --git a/homeassistant/components/tailwind/config_flow.py b/homeassistant/components/tailwind/config_flow.py index 48fe2d23727de..ce5deab164d31 100644 --- a/homeassistant/components/tailwind/config_flow.py +++ b/homeassistant/components/tailwind/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any +from typing import TYPE_CHECKING, Any from gotailwind import ( MIN_REQUIRED_FIRMWARE_VERSION, @@ -15,8 +15,6 @@ ) import voluptuous as vol -from homeassistant.components import zeroconf -from homeassistant.components.dhcp import DhcpServiceInfo from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_TOKEN from homeassistant.data_entry_flow import AbortFlow @@ -30,6 +28,10 @@ from .const import DOMAIN, LOGGER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + LOCAL_CONTROL_KEY_URL = ( "https://web.gotailwind.com/client/integration/local-control-key" ) @@ -83,7 +85,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery of a Tailwind device.""" if not (device_id := discovery_info.properties.get("device_id")): diff --git a/homeassistant/components/technove/config_flow.py b/homeassistant/components/technove/config_flow.py index 0e4f026ba5c99..78dde7ffed6c4 100644 --- a/homeassistant/components/technove/config_flow.py +++ b/homeassistant/components/technove/config_flow.py @@ -1,17 +1,22 @@ """Config flow for TechnoVE.""" -from typing import Any +from __future__ import annotations + +from typing import TYPE_CHECKING, Any from technove import Station as TechnoVEStation, TechnoVE, TechnoVEConnectionError import voluptuous as vol -from homeassistant.components import onboarding, zeroconf +from homeassistant.components import onboarding from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MAC from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class TechnoVEConfigFlow(ConfigFlow, domain=DOMAIN): """Handle a config flow for TechnoVE.""" @@ -49,7 +54,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" # Abort quick if the device with provided mac is already configured diff --git a/homeassistant/components/tesla_wall_connector/config_flow.py b/homeassistant/components/tesla_wall_connector/config_flow.py index 3296539f701ef..0d0db2e1e9e79 100644 --- a/homeassistant/components/tesla_wall_connector/config_flow.py +++ b/homeassistant/components/tesla_wall_connector/config_flow.py @@ -3,13 +3,12 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from tesla_wall_connector import WallConnector from tesla_wall_connector.exceptions import WallConnectorError import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant @@ -17,6 +16,9 @@ from .const import DOMAIN, WALLCONNECTOR_DEVICE_NAME, WALLCONNECTOR_SERIAL_NUMBER +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -48,7 +50,7 @@ def __init__(self) -> None: self.ip_address: str | None = None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" self.ip_address = discovery_info.ip diff --git a/homeassistant/components/tolo/config_flow.py b/homeassistant/components/tolo/config_flow.py index d5d7e33a5e008..fbe9532c195fb 100644 --- a/homeassistant/components/tolo/config_flow.py +++ b/homeassistant/components/tolo/config_flow.py @@ -3,18 +3,20 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from tololib import ToloClient, ToloCommunicationError import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.helpers.device_registry import format_mac from .const import DEFAULT_NAME, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -61,7 +63,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle a flow initialized by discovery.""" await self.async_set_unique_id(format_mac(discovery_info.macaddress)) diff --git a/homeassistant/components/tplink/config_flow.py b/homeassistant/components/tplink/config_flow.py index 9bc278f8948b3..457483e7a2a7b 100644 --- a/homeassistant/components/tplink/config_flow.py +++ b/homeassistant/components/tplink/config_flow.py @@ -18,7 +18,7 @@ ) import voluptuous as vol -from homeassistant.components import dhcp, ffmpeg, stream +from homeassistant.components import ffmpeg, stream from homeassistant.config_entries import ( SOURCE_REAUTH, SOURCE_RECONFIGURE, @@ -61,6 +61,9 @@ DOMAIN, ) +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) STEP_AUTH_DATA_SCHEMA = vol.Schema( @@ -93,7 +96,7 @@ def __init__(self) -> None: self._discovered_device: Device | None = None async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" return await self._async_handle_discovery( diff --git a/homeassistant/components/twinkly/config_flow.py b/homeassistant/components/twinkly/config_flow.py index 53ba8f084c362..0cc7341d98f1c 100644 --- a/homeassistant/components/twinkly/config_flow.py +++ b/homeassistant/components/twinkly/config_flow.py @@ -3,19 +3,21 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import ClientError from ttls.client import Twinkly from voluptuous import Required, Schema -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DEV_ID, DEV_MODEL, DEV_NAME, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -58,7 +60,7 @@ async def async_step_user( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery for twinkly.""" self._async_abort_entries_match({CONF_HOST: discovery_info.ip}) diff --git a/homeassistant/components/unifiprotect/config_flow.py b/homeassistant/components/unifiprotect/config_flow.py index 31950f8f7e44e..a9e4adad651f5 100644 --- a/homeassistant/components/unifiprotect/config_flow.py +++ b/homeassistant/components/unifiprotect/config_flow.py @@ -5,7 +5,7 @@ from collections.abc import Mapping import logging from pathlib import Path -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp import CookieJar from uiprotect import ProtectApiClient @@ -14,7 +14,6 @@ from unifi_discovery import async_console_is_alive import voluptuous as vol -from homeassistant.components import dhcp, ssdp from homeassistant.config_entries import ( SOURCE_IGNORE, ConfigEntry, @@ -58,6 +57,10 @@ from .discovery import async_start_discovery from .utils import _async_resolve, _async_short_mac, _async_unifi_mac_from_hass +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.ssdp import SsdpServiceInfo + _LOGGER = logging.getLogger(__name__) ENTRY_FAILURE_STATES = ( @@ -107,14 +110,14 @@ def __init__(self) -> None: self._discovered_device: dict[str, str] = {} async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" _LOGGER.debug("Starting discovery via: %s", discovery_info) return await self._async_discovery_handoff() async def async_step_ssdp( - self, discovery_info: ssdp.SsdpServiceInfo + self, discovery_info: SsdpServiceInfo ) -> ConfigFlowResult: """Handle a discovered UniFi device.""" _LOGGER.debug("Starting discovery via: %s", discovery_info) diff --git a/homeassistant/components/vicare/config_flow.py b/homeassistant/components/vicare/config_flow.py index 6594e6ec9e47a..a0f603264b6e2 100644 --- a/homeassistant/components/vicare/config_flow.py +++ b/homeassistant/components/vicare/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping import logging -from typing import Any +from typing import TYPE_CHECKING, Any from PyViCare.PyViCareUtils import ( PyViCareInvalidConfigurationError, @@ -12,7 +12,6 @@ ) import voluptuous as vol -from homeassistant.components import dhcp from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME import homeassistant.helpers.config_validation as cv @@ -27,6 +26,9 @@ ) from .utils import login +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) REAUTH_SCHEMA = vol.Schema( @@ -109,7 +111,7 @@ async def async_step_reauth_confirm( ) async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Invoke when a Viessmann MAC address is discovered on the network.""" formatted_mac = format_mac(discovery_info.macaddress) diff --git a/homeassistant/components/vizio/config_flow.py b/homeassistant/components/vizio/config_flow.py index d3921061d8e94..d5ace9ebd9b6a 100644 --- a/homeassistant/components/vizio/config_flow.py +++ b/homeassistant/components/vizio/config_flow.py @@ -5,13 +5,12 @@ import copy import logging import socket -from typing import Any +from typing import TYPE_CHECKING, Any from pyvizio import VizioAsync, async_guess_device_type from pyvizio.const import APP_HOME import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.components.media_player import MediaPlayerDeviceClass from homeassistant.config_entries import ( SOURCE_ZEROCONF, @@ -46,6 +45,9 @@ DOMAIN, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -257,7 +259,7 @@ async def async_step_user( return self.async_show_form(step_id="user", data_schema=schema, errors=errors) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" host = discovery_info.host diff --git a/homeassistant/components/volumio/config_flow.py b/homeassistant/components/volumio/config_flow.py index 7cc58556f3e73..b8e3e5ccf8d09 100644 --- a/homeassistant/components/volumio/config_flow.py +++ b/homeassistant/components/volumio/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pyvolumio import CannotConnectError, Volumio import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT from homeassistant.core import HomeAssistant, callback @@ -17,6 +16,9 @@ from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) @@ -97,7 +99,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" self._host = discovery_info.host diff --git a/homeassistant/components/wiz/config_flow.py b/homeassistant/components/wiz/config_flow.py index 71bc0a9aaa868..40e84c211876d 100644 --- a/homeassistant/components/wiz/config_flow.py +++ b/homeassistant/components/wiz/config_flow.py @@ -3,14 +3,14 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from pywizlight import wizlight from pywizlight.discovery import DiscoveredBulb from pywizlight.exceptions import WizLightConnectionError, WizLightTimeOutError import voluptuous as vol -from homeassistant.components import dhcp, onboarding +from homeassistant.components import onboarding from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.data_entry_flow import AbortFlow @@ -20,6 +20,9 @@ from .discovery import async_discover_devices from .utils import _short_mac, name_from_bulb_type_and_mac +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) CONF_DEVICE = "device" @@ -38,7 +41,7 @@ def __init__(self) -> None: self._discovered_devices: dict[str, DiscoveredBulb] = {} async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery via dhcp.""" self._discovered_device = DiscoveredBulb( diff --git a/homeassistant/components/wled/config_flow.py b/homeassistant/components/wled/config_flow.py index 812a0500d1a38..b83d5fe4f887d 100644 --- a/homeassistant/components/wled/config_flow.py +++ b/homeassistant/components/wled/config_flow.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any import voluptuous as vol from wled import WLED, Device, WLEDConnectionError -from homeassistant.components import onboarding, zeroconf +from homeassistant.components import onboarding from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -20,6 +20,9 @@ from .const import CONF_KEEP_MAIN_LIGHT, DEFAULT_KEEP_MAIN_LIGHT, DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + class WLEDFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a WLED config flow.""" @@ -68,7 +71,7 @@ async def async_step_user( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" # Abort quick if the mac address is provided by discovery info diff --git a/homeassistant/components/wmspro/config_flow.py b/homeassistant/components/wmspro/config_flow.py index 2ce58ec9ecaaa..cd88c31767087 100644 --- a/homeassistant/components/wmspro/config_flow.py +++ b/homeassistant/components/wmspro/config_flow.py @@ -4,21 +4,22 @@ import ipaddress import logging -from typing import Any +from typing import TYPE_CHECKING, Any import aiohttp import voluptuous as vol from wmspro.webcontrol import WebControlPro -from homeassistant.components import dhcp -from homeassistant.components.dhcp import DhcpServiceInfo -from homeassistant.config_entries import ConfigFlow, ConfigFlowResult +from homeassistant.config_entries import SOURCE_DHCP, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.device_registry import format_mac from .const import DOMAIN, SUGGESTED_HOST +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + _LOGGER = logging.getLogger(__name__) STEP_USER_DATA_SCHEMA = vol.Schema( @@ -34,7 +35,7 @@ class WebControlProConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle the DHCP discovery step.""" unique_id = format_mac(discovery_info.macaddress) @@ -95,7 +96,7 @@ async def async_step_user( return self.async_abort(reason="already_configured") return self.async_create_entry(title=host, data=user_input) - if self.source == dhcp.DOMAIN: + if self.source == SOURCE_DHCP: discovery_info: DhcpServiceInfo = self.init_data data_values = {CONF_HOST: discovery_info.ip} else: diff --git a/homeassistant/components/wyoming/config_flow.py b/homeassistant/components/wyoming/config_flow.py index ddf57cf0ed06b..5a92aafafabe9 100644 --- a/homeassistant/components/wyoming/config_flow.py +++ b/homeassistant/components/wyoming/config_flow.py @@ -3,12 +3,11 @@ from __future__ import annotations import logging -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urlparse import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import SOURCE_HASSIO, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.helpers.service_info.hassio import HassioServiceInfo @@ -16,6 +15,9 @@ from .const import DOMAIN from .data import WyomingService +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) STEP_USER_DATA_SCHEMA = vol.Schema( @@ -117,7 +119,7 @@ async def async_step_hassio_confirm( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" _LOGGER.debug("Zeroconf discovery info: %s", discovery_info) diff --git a/homeassistant/components/xiaomi_aqara/config_flow.py b/homeassistant/components/xiaomi_aqara/config_flow.py index 6252e6849d029..d66fbff4c6973 100644 --- a/homeassistant/components/xiaomi_aqara/config_flow.py +++ b/homeassistant/components/xiaomi_aqara/config_flow.py @@ -1,13 +1,14 @@ """Config flow to configure Xiaomi Aqara.""" +from __future__ import annotations + import logging from socket import gaierror -from typing import Any +from typing import TYPE_CHECKING, Any import voluptuous as vol from xiaomi_gateway import MULTICAST_PORT, XiaomiGateway, XiaomiGatewayDiscovery -from homeassistant.components import zeroconf from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_PROTOCOL from homeassistant.core import callback @@ -23,6 +24,9 @@ ZEROCONF_GATEWAY, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) DEFAULT_GATEWAY_NAME = "Xiaomi Aqara Gateway" @@ -153,7 +157,7 @@ async def async_step_select( ) async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" name = discovery_info.name diff --git a/homeassistant/components/xiaomi_miio/config_flow.py b/homeassistant/components/xiaomi_miio/config_flow.py index b068f4a1e61c8..ba02b8205e2a3 100644 --- a/homeassistant/components/xiaomi_miio/config_flow.py +++ b/homeassistant/components/xiaomi_miio/config_flow.py @@ -5,13 +5,12 @@ from collections.abc import Mapping import logging from re import search -from typing import Any +from typing import TYPE_CHECKING, Any from micloud import MiCloud from micloud.micloudexception import MiCloudAccessDenied import voluptuous as vol -from homeassistant.components import zeroconf from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, @@ -41,6 +40,9 @@ ) from .device import ConnectXiaomiDevice +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) DEVICE_SETTINGS = { @@ -145,7 +147,7 @@ async def async_step_user( return await self.async_step_cloud() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" name = discovery_info.name diff --git a/homeassistant/components/yeelight/config_flow.py b/homeassistant/components/yeelight/config_flow.py index 7a3a0a2f10000..7132204e02f7c 100644 --- a/homeassistant/components/yeelight/config_flow.py +++ b/homeassistant/components/yeelight/config_flow.py @@ -3,7 +3,7 @@ from __future__ import annotations import logging -from typing import Any, Self +from typing import TYPE_CHECKING, Any, Self from urllib.parse import urlparse import voluptuous as vol @@ -11,7 +11,7 @@ from yeelight.aio import AsyncBulb from yeelight.main import get_known_models -from homeassistant.components import dhcp, onboarding, ssdp, zeroconf +from homeassistant.components import onboarding, ssdp from homeassistant.config_entries import ( ConfigEntry, ConfigEntryState, @@ -43,6 +43,10 @@ ) from .scanner import YeelightScanner +if TYPE_CHECKING: + from homeassistant.components.dhcp import DhcpServiceInfo + from homeassistant.components.zeroconf import ZeroconfServiceInfo + MODEL_UNKNOWN = "unknown" _LOGGER = logging.getLogger(__name__) @@ -69,21 +73,21 @@ def __init__(self) -> None: self._discovered_devices: dict[str, Any] = {} async def async_step_homekit( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle discovery from homekit.""" self._discovered_ip = discovery_info.host return await self._async_handle_discovery() async def async_step_dhcp( - self, discovery_info: dhcp.DhcpServiceInfo + self, discovery_info: DhcpServiceInfo ) -> ConfigFlowResult: """Handle discovery from dhcp.""" self._discovered_ip = discovery_info.ip return await self._async_handle_discovery() async def async_step_zeroconf( - self, discovery_info: zeroconf.ZeroconfServiceInfo + self, discovery_info: ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle discovery from zeroconf.""" self._discovered_ip = discovery_info.host diff --git a/homeassistant/components/zwave_js/config_flow.py b/homeassistant/components/zwave_js/config_flow.py index 711eb14070de2..7d37181df860e 100644 --- a/homeassistant/components/zwave_js/config_flow.py +++ b/homeassistant/components/zwave_js/config_flow.py @@ -5,7 +5,7 @@ from abc import ABC, abstractmethod import asyncio import logging -from typing import Any +from typing import TYPE_CHECKING, Any import aiohttp from serial.tools import list_ports @@ -19,7 +19,6 @@ AddonManager, AddonState, ) -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ( SOURCE_USB, ConfigEntriesFlowManager, @@ -67,6 +66,9 @@ DOMAIN, ) +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__) DEFAULT_URL = "ws://localhost:3000" diff --git a/homeassistant/components/zwave_me/config_flow.py b/homeassistant/components/zwave_me/config_flow.py index 1444bfc1b9568..3dbfaec408afb 100644 --- a/homeassistant/components/zwave_me/config_flow.py +++ b/homeassistant/components/zwave_me/config_flow.py @@ -3,17 +3,20 @@ from __future__ import annotations import logging +from typing import TYPE_CHECKING from url_normalize import url_normalize import voluptuous as vol -from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_TOKEN, CONF_URL from . import helpers from .const import DOMAIN +if TYPE_CHECKING: + from homeassistant.components.zeroconf import ZeroconfServiceInfo + _LOGGER = logging.getLogger(__name__)