Update coordinator typing (7) [w-z] (#68467)

pull/68470/head
Marc Mueller 2022-03-21 15:29:11 +01:00 committed by GitHub
parent 539a469a8b
commit 129c9e42f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 27 additions and 31 deletions

View File

@ -148,11 +148,9 @@ class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""
class WallboxEntity(CoordinatorEntity):
class WallboxEntity(CoordinatorEntity[WallboxCoordinator]):
"""Defines a base Wallbox entity."""
coordinator: WallboxCoordinator
@property
def device_info(self) -> DeviceInfo:
"""Return device information about this Wallbox device."""

View File

@ -59,7 +59,6 @@ class WallboxNumber(WallboxEntity, NumberEntity):
"""Representation of the Wallbox portal."""
entity_description: WallboxNumberEntityDescription
coordinator: WallboxCoordinator
def __init__(
self,

View File

@ -152,7 +152,6 @@ class WallboxSensor(WallboxEntity, SensorEntity):
"""Representation of the Wallbox portal."""
entity_description: WallboxSensorEntityDescription
coordinator: WallboxCoordinator
def __init__(
self,

View File

@ -16,11 +16,9 @@ from .wemo_device import DeviceCoordinator
_LOGGER = logging.getLogger(__name__)
class WemoEntity(CoordinatorEntity):
class WemoEntity(CoordinatorEntity[DeviceCoordinator]):
"""Common methods for Wemo entities."""
coordinator: DeviceCoordinator # Override CoordinatorEntity.coordinator type.
# Most pyWeMo devices are associated with a single Home Assistant entity. When
# that is not the case, name_suffix & unique_id_suffix can be used to provide
# names and unique ids for additional Home Assistant entities.

View File

@ -7,11 +7,9 @@ from .const import DOMAIN
from .coordinator import WLEDDataUpdateCoordinator
class WLEDEntity(CoordinatorEntity):
class WLEDEntity(CoordinatorEntity[WLEDDataUpdateCoordinator]):
"""Defines a base WLED entity."""
coordinator: WLEDDataUpdateCoordinator
@property
def device_info(self) -> DeviceInfo:
"""Return device information about this WLED device."""

View File

@ -11,7 +11,7 @@ from . import PresenceData, XboxUpdateCoordinator
from .const import DOMAIN
class XboxBaseSensorEntity(CoordinatorEntity):
class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
"""Base Sensor for the Xbox Integration."""
def __init__(

View File

@ -78,7 +78,7 @@ async def async_setup_entry(
)
class XboxMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
class XboxMediaPlayer(CoordinatorEntity[XboxUpdateCoordinator], MediaPlayerEntity):
"""Representation of an Xbox Media Player."""
def __init__(

View File

@ -45,7 +45,7 @@ async def async_setup_entry(
)
class XboxRemote(CoordinatorEntity, RemoteEntity):
class XboxRemote(CoordinatorEntity[XboxUpdateCoordinator], RemoteEntity):
"""Representation of an Xbox remote."""
def __init__(

View File

@ -3,6 +3,7 @@ import datetime
from enum import Enum
from functools import partial
import logging
from typing import Any, TypeVar
from construct.core import ChecksumError
from miio import Device, DeviceException
@ -10,12 +11,17 @@ from miio import Device, DeviceException
from homeassistant.const import ATTR_CONNECTIONS
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
)
from .const import CONF_MAC, CONF_MODEL, DOMAIN, AuthException, SetupException
_LOGGER = logging.getLogger(__name__)
_T = TypeVar("_T", bound=DataUpdateCoordinator[Any])
class ConnectXiaomiDevice:
"""Class to async connect to a Xiaomi Device."""
@ -101,7 +107,7 @@ class XiaomiMiioEntity(Entity):
return device_info
class XiaomiCoordinatedMiioEntity(CoordinatorEntity):
class XiaomiCoordinatedMiioEntity(CoordinatorEntity[_T]):
"""Representation of a base a coordinated Xiaomi Miio Entity."""
def __init__(self, name, device, entry, unique_id, coordinator):

View File

@ -203,13 +203,19 @@ async def async_setup_entry(
async_add_entities(entities, update_before_add=True)
class MiroboVacuum(XiaomiCoordinatedMiioEntity, StateVacuumEntity):
class MiroboVacuum(
XiaomiCoordinatedMiioEntity[DataUpdateCoordinator[VacuumCoordinatorData]],
StateVacuumEntity,
):
"""Representation of a Xiaomi Vacuum cleaner robot."""
coordinator: DataUpdateCoordinator[VacuumCoordinatorData]
def __init__(
self, name, device, entry, unique_id, coordinator: DataUpdateCoordinator
self,
name,
device,
entry,
unique_id,
coordinator: DataUpdateCoordinator[VacuumCoordinatorData],
):
"""Initialize the Xiaomi vacuum cleaner robot handler."""
super().__init__(name, device, entry, unique_id, coordinator)

View File

@ -81,8 +81,6 @@ async def async_setup_entry(
class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
"""Represent a Yale Smart Alarm."""
coordinator: YaleDataUpdateCoordinator
_attr_code_arm_required = False
_attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY

View File

@ -9,11 +9,9 @@ from .const import DOMAIN, MANUFACTURER, MODEL
from .coordinator import YaleDataUpdateCoordinator
class YaleEntity(CoordinatorEntity, Entity):
class YaleEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
"""Base implementation for Yale device."""
coordinator: YaleDataUpdateCoordinator
def __init__(self, coordinator: YaleDataUpdateCoordinator, data: dict) -> None:
"""Initialize an Yale device."""
super().__init__(coordinator)
@ -28,11 +26,9 @@ class YaleEntity(CoordinatorEntity, Entity):
)
class YaleAlarmEntity(CoordinatorEntity, Entity):
class YaleAlarmEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
"""Base implementation for Yale Alarm device."""
coordinator: YaleDataUpdateCoordinator
def __init__(self, coordinator: YaleDataUpdateCoordinator) -> None:
"""Initialize an Yale device."""
super().__init__(coordinator)

View File

@ -120,11 +120,9 @@ class MusicCastDataUpdateCoordinator(DataUpdateCoordinator[MusicCastData]):
return self.musiccast.data
class MusicCastEntity(CoordinatorEntity):
class MusicCastEntity(CoordinatorEntity[MusicCastDataUpdateCoordinator]):
"""Defines a base MusicCast entity."""
coordinator: MusicCastDataUpdateCoordinator
def __init__(
self,
*,