Move some bleak imports to be behind TYPE_CHECKING (#75894)
This commit is contained in:
parent
9f16c14681
commit
4b2beda473
3 changed files with 16 additions and 7 deletions
|
@ -3,11 +3,9 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Any, cast
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
from bleak.backends.device import BLEDevice
|
||||
import switchbot
|
||||
from switchbot import parse_advertisement_data
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
from homeassistant.components.bluetooth.passive_update_coordinator import (
|
||||
|
@ -15,6 +13,10 @@ from homeassistant.components.bluetooth.passive_update_coordinator import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bleak.backends.device import BLEDevice
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -52,7 +54,7 @@ class SwitchbotDataUpdateCoordinator(PassiveBluetoothDataUpdateCoordinator):
|
|||
"""Handle a Bluetooth event."""
|
||||
super()._async_handle_bluetooth_event(service_info, change)
|
||||
discovery_info_bleak = cast(bluetooth.BluetoothServiceInfoBleak, service_info)
|
||||
if adv := parse_advertisement_data(
|
||||
if adv := switchbot.parse_advertisement_data(
|
||||
discovery_info_bleak.device, discovery_info_bleak.advertisement
|
||||
):
|
||||
self.data = flatten_sensors_data(adv.data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue