Update coordinator typing (1) [a-c] (#68442)

This commit is contained in:
Marc Mueller 2022-03-21 15:49:39 +01:00 committed by GitHub
parent 40d4495ed0
commit 1072aff017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 28 additions and 37 deletions

View File

@ -58,11 +58,12 @@ async def async_setup_entry(
async_add_entities(sensors) async_add_entities(sensors)
class AccuWeatherSensor(CoordinatorEntity, SensorEntity): class AccuWeatherSensor(
CoordinatorEntity[AccuWeatherDataUpdateCoordinator], SensorEntity
):
"""Define an AccuWeather entity.""" """Define an AccuWeather entity."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION
coordinator: AccuWeatherDataUpdateCoordinator
entity_description: AccuWeatherSensorDescription entity_description: AccuWeatherSensorDescription
def __init__( def __init__(

View File

@ -56,11 +56,11 @@ async def async_setup_entry(
async_add_entities([AccuWeatherEntity(name, coordinator)]) async_add_entities([AccuWeatherEntity(name, coordinator)])
class AccuWeatherEntity(CoordinatorEntity, WeatherEntity): class AccuWeatherEntity(
CoordinatorEntity[AccuWeatherDataUpdateCoordinator], WeatherEntity
):
"""Define an AccuWeather entity.""" """Define an AccuWeather entity."""
coordinator: AccuWeatherDataUpdateCoordinator
def __init__( def __init__(
self, name: str, coordinator: AccuWeatherDataUpdateCoordinator self, name: str, coordinator: AccuWeatherDataUpdateCoordinator
) -> None: ) -> None:

View File

@ -64,7 +64,7 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
class AbstractAemetSensor(CoordinatorEntity, SensorEntity): class AbstractAemetSensor(CoordinatorEntity[WeatherUpdateCoordinator], SensorEntity):
"""Abstract class for an AEMET OpenData sensor.""" """Abstract class for an AEMET OpenData sensor."""
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} _attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}

View File

@ -43,7 +43,7 @@ async def async_setup_entry(
async_add_entities(entities, False) async_add_entities(entities, False)
class AemetWeather(CoordinatorEntity, WeatherEntity): class AemetWeather(CoordinatorEntity[WeatherUpdateCoordinator], WeatherEntity):
"""Implementation of an AEMET OpenData sensor.""" """Implementation of an AEMET OpenData sensor."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION

View File

@ -134,10 +134,9 @@ async def async_setup_entry(
async_add_entities(sensors, False) async_add_entities(sensors, False)
class AirlySensor(CoordinatorEntity, SensorEntity): class AirlySensor(CoordinatorEntity[AirlyDataUpdateCoordinator], SensorEntity):
"""Define an Airly sensor.""" """Define an Airly sensor."""
coordinator: AirlyDataUpdateCoordinator
entity_description: AirlySensorEntityDescription entity_description: AirlySensorEntityDescription
def __init__( def __init__(

View File

@ -70,11 +70,9 @@ async def async_setup_entry(
async_add_entities(entities, False) async_add_entities(entities, False)
class AirNowSensor(CoordinatorEntity, SensorEntity): class AirNowSensor(CoordinatorEntity[AirNowDataUpdateCoordinator], SensorEntity):
"""Define an AirNow sensor.""" """Define an AirNow sensor."""
coordinator: AirNowDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: AirNowDataUpdateCoordinator, coordinator: AirNowDataUpdateCoordinator,

View File

@ -20,7 +20,7 @@ from .coordinator import AirzoneUpdateCoordinator
PLATFORMS: list[Platform] = [Platform.SENSOR] PLATFORMS: list[Platform] = [Platform.SENSOR]
class AirzoneEntity(CoordinatorEntity): class AirzoneEntity(CoordinatorEntity[AirzoneUpdateCoordinator]):
"""Define an Airzone entity.""" """Define an Airzone entity."""
def __init__( def __init__(

View File

@ -24,7 +24,9 @@ PRICE_SPIKE_ICONS = {
} }
class AmberPriceGridSensor(CoordinatorEntity, BinarySensorEntity): class AmberPriceGridSensor(
CoordinatorEntity[AmberUpdateCoordinator], BinarySensorEntity
):
"""Sensor to show single grid binary values.""" """Sensor to show single grid binary values."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION

View File

@ -51,7 +51,7 @@ def friendly_channel_type(channel_type: str) -> str:
return "General" return "General"
class AmberSensor(CoordinatorEntity, SensorEntity): class AmberSensor(CoordinatorEntity[AmberUpdateCoordinator], SensorEntity):
"""Amber Base Sensor.""" """Amber Base Sensor."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION
@ -180,7 +180,7 @@ class AmberPriceDescriptorSensor(AmberSensor):
return self.coordinator.data[self.entity_description.key][self.channel_type] return self.coordinator.data[self.entity_description.key][self.channel_type]
class AmberGridSensor(CoordinatorEntity, SensorEntity): class AmberGridSensor(CoordinatorEntity[AmberUpdateCoordinator], SensorEntity):
"""Sensor to show single grid specific values.""" """Sensor to show single grid specific values."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION

View File

@ -8,11 +8,9 @@ from . import AsekoDataUpdateCoordinator
from .const import DOMAIN from .const import DOMAIN
class AsekoEntity(CoordinatorEntity): class AsekoEntity(CoordinatorEntity[AsekoDataUpdateCoordinator]):
"""Representation of an aseko entity.""" """Representation of an aseko entity."""
coordinator: AsekoDataUpdateCoordinator
def __init__(self, unit: Unit, coordinator: AsekoDataUpdateCoordinator) -> None: def __init__(self, unit: Unit, coordinator: AsekoDataUpdateCoordinator) -> None:
"""Initialize the aseko entity.""" """Initialize the aseko entity."""
super().__init__(coordinator) super().__init__(coordinator)

View File

@ -118,7 +118,7 @@ class AuroraDataUpdateCoordinator(DataUpdateCoordinator):
raise UpdateFailed(f"Error updating from NOAA: {error}") from error raise UpdateFailed(f"Error updating from NOAA: {error}") from error
class AuroraEntity(CoordinatorEntity): class AuroraEntity(CoordinatorEntity[AuroraDataUpdateCoordinator]):
"""Implementation of the base Aurora Entity.""" """Implementation of the base Aurora Entity."""
_attr_extra_state_attributes = {"attribution": ATTRIBUTION} _attr_extra_state_attributes = {"attribution": ATTRIBUTION}

View File

@ -102,7 +102,7 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
class AwairSensor(CoordinatorEntity, SensorEntity): class AwairSensor(CoordinatorEntity[AwairDataUpdateCoordinator], SensorEntity):
"""Defines an Awair sensor entity.""" """Defines an Awair sensor entity."""
entity_description: AwairSensorEntityDescription entity_description: AwairSensorEntityDescription

View File

@ -94,10 +94,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok return unload_ok
class AzureDevOpsEntity(CoordinatorEntity): class AzureDevOpsEntity(CoordinatorEntity[DataUpdateCoordinator[list[DevOpsBuild]]]):
"""Defines a base Azure DevOps entity.""" """Defines a base Azure DevOps entity."""
coordinator: DataUpdateCoordinator[list[DevOpsBuild]]
entity_description: AzureDevOpsEntityDescription entity_description: AzureDevOpsEntityDescription
def __init__( def __init__(

View File

@ -67,10 +67,9 @@ async def async_setup_entry(
) )
class BraviaTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity): class BraviaTVMediaPlayer(CoordinatorEntity[BraviaTVCoordinator], MediaPlayerEntity):
"""Representation of a Bravia TV Media Player.""" """Representation of a Bravia TV Media Player."""
coordinator: BraviaTVCoordinator
_attr_device_class = MediaPlayerDeviceClass.TV _attr_device_class = MediaPlayerDeviceClass.TV
_attr_supported_features = SUPPORT_BRAVIA _attr_supported_features = SUPPORT_BRAVIA

View File

@ -37,11 +37,9 @@ async def async_setup_entry(
) )
class BraviaTVRemote(CoordinatorEntity, RemoteEntity): class BraviaTVRemote(CoordinatorEntity[BraviaTVCoordinator], RemoteEntity):
"""Representation of a Bravia TV Remote.""" """Representation of a Bravia TV Remote."""
coordinator: BraviaTVCoordinator
def __init__( def __init__(
self, self,
coordinator: BraviaTVCoordinator, coordinator: BraviaTVCoordinator,

View File

@ -48,10 +48,11 @@ async def async_setup_entry(
async_add_entities(alarms, True) async_add_entities(alarms, True)
class CanaryAlarm(CoordinatorEntity, AlarmControlPanelEntity): class CanaryAlarm(
CoordinatorEntity[CanaryDataUpdateCoordinator], AlarmControlPanelEntity
):
"""Representation of a Canary alarm control panel.""" """Representation of a Canary alarm control panel."""
coordinator: CanaryDataUpdateCoordinator
_attr_supported_features = ( _attr_supported_features = (
SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT
) )

View File

@ -78,11 +78,9 @@ async def async_setup_entry(
async_add_entities(cameras, True) async_add_entities(cameras, True)
class CanaryCamera(CoordinatorEntity, Camera): class CanaryCamera(CoordinatorEntity[CanaryDataUpdateCoordinator], Camera):
"""An implementation of a Canary security camera.""" """An implementation of a Canary security camera."""
coordinator: CanaryDataUpdateCoordinator
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,

View File

@ -76,11 +76,9 @@ async def async_setup_entry(
async_add_entities(sensors, True) async_add_entities(sensors, True)
class CanarySensor(CoordinatorEntity, SensorEntity): class CanarySensor(CoordinatorEntity[CanaryDataUpdateCoordinator], SensorEntity):
"""Representation of a Canary sensor.""" """Representation of a Canary sensor."""
coordinator: CanaryDataUpdateCoordinator
def __init__( def __init__(
self, self,
coordinator: CanaryDataUpdateCoordinator, coordinator: CanaryDataUpdateCoordinator,

View File

@ -273,7 +273,7 @@ class ClimaCellDataUpdateCoordinator(DataUpdateCoordinator):
return data return data
class ClimaCellEntity(CoordinatorEntity): class ClimaCellEntity(CoordinatorEntity[ClimaCellDataUpdateCoordinator]):
"""Base ClimaCell Entity.""" """Base ClimaCell Entity."""
def __init__( def __init__(