mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Avoid importing MQTT into core for ServiceInfo dataclass (#74418)
* Avoid importing MQTT into core for discovery dataclass Likely fixes #73863 * relo * adjust * rename * rename * rename * adjust missed imports * drop compat * fix conflict correctly * Update homeassistant/helpers/config_entry_flow.py * fix black from trying to fix the conflict in github
This commit is contained in:
@@ -6,7 +6,7 @@ import logging
|
||||
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Union, cast
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import bluetooth, dhcp, onboarding, ssdp, zeroconf
|
||||
from homeassistant.components import onboarding
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
@@ -15,8 +15,12 @@ from .typing import UNDEFINED, DiscoveryInfoType, UndefinedType
|
||||
if TYPE_CHECKING:
|
||||
import asyncio
|
||||
|
||||
from homeassistant.components import mqtt
|
||||
from homeassistant.components.bluetooth import BluetoothServiceInfo
|
||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||
from homeassistant.components.ssdp import SsdpServiceInfo
|
||||
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from .service_info.mqtt import MqttServiceInfo
|
||||
|
||||
_R = TypeVar("_R", bound="Awaitable[bool] | bool")
|
||||
DiscoveryFunctionType = Callable[[HomeAssistant], _R]
|
||||
@@ -93,7 +97,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]):
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def async_step_bluetooth(
|
||||
self, discovery_info: bluetooth.BluetoothServiceInfo
|
||||
self, discovery_info: BluetoothServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initialized by bluetooth discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
@@ -103,7 +107,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]):
|
||||
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle a flow initialized by dhcp discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
@@ -113,7 +117,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]):
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def async_step_homekit(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
self, discovery_info: ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initialized by Homekit discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
@@ -123,7 +127,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]):
|
||||
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def async_step_mqtt(self, discovery_info: mqtt.MqttServiceInfo) -> FlowResult:
|
||||
async def async_step_mqtt(self, discovery_info: MqttServiceInfo) -> FlowResult:
|
||||
"""Handle a flow initialized by mqtt discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
@@ -133,7 +137,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]):
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
self, discovery_info: ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initialized by Zeroconf discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
@@ -143,7 +147,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]):
|
||||
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(self, discovery_info: SsdpServiceInfo) -> FlowResult:
|
||||
"""Handle a flow initialized by Ssdp discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
Reference in New Issue
Block a user