From b664bcd0070fc19a4c92021c3ce469ae60f4d737 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:45:24 +0100 Subject: [PATCH] Update coordinator typing (4) [o-p] (#68464) --- homeassistant/components/octoprint/binary_sensor.py | 6 +++--- homeassistant/components/octoprint/button.py | 3 +-- homeassistant/components/octoprint/sensor.py | 6 +++--- homeassistant/components/omnilogic/common.py | 2 +- homeassistant/components/open_meteo/weather.py | 10 +++++++--- homeassistant/components/overkiz/entity.py | 4 +--- homeassistant/components/p1_monitor/sensor.py | 6 +++--- homeassistant/components/philips_js/light.py | 4 +++- homeassistant/components/philips_js/media_player.py | 5 +++-- homeassistant/components/philips_js/remote.py | 4 +--- homeassistant/components/philips_js/switch.py | 6 +++--- homeassistant/components/pvoutput/sensor.py | 5 +++-- homeassistant/components/pvpc_hourly_pricing/sensor.py | 4 +--- 13 files changed, 33 insertions(+), 32 deletions(-) diff --git a/homeassistant/components/octoprint/binary_sensor.py b/homeassistant/components/octoprint/binary_sensor.py index e1db7a95136..b0e43bd74e0 100644 --- a/homeassistant/components/octoprint/binary_sensor.py +++ b/homeassistant/components/octoprint/binary_sensor.py @@ -36,11 +36,11 @@ async def async_setup_entry( async_add_entities(entities) -class OctoPrintBinarySensorBase(CoordinatorEntity, BinarySensorEntity): +class OctoPrintBinarySensorBase( + CoordinatorEntity[OctoprintDataUpdateCoordinator], BinarySensorEntity +): """Representation an OctoPrint binary sensor.""" - coordinator: OctoprintDataUpdateCoordinator - def __init__( self, coordinator: OctoprintDataUpdateCoordinator, diff --git a/homeassistant/components/octoprint/button.py b/homeassistant/components/octoprint/button.py index 97676592f47..e16f123a73a 100644 --- a/homeassistant/components/octoprint/button.py +++ b/homeassistant/components/octoprint/button.py @@ -34,10 +34,9 @@ async def async_setup_entry( ) -class OctoprintButton(CoordinatorEntity, ButtonEntity): +class OctoprintButton(CoordinatorEntity[OctoprintDataUpdateCoordinator], ButtonEntity): """Represent an OctoPrint binary sensor.""" - coordinator: OctoprintDataUpdateCoordinator client: OctoprintClient def __init__( diff --git a/homeassistant/components/octoprint/sensor.py b/homeassistant/components/octoprint/sensor.py index 5a094c10987..4efc094c297 100644 --- a/homeassistant/components/octoprint/sensor.py +++ b/homeassistant/components/octoprint/sensor.py @@ -89,11 +89,11 @@ async def async_setup_entry( async_add_entities(entities) -class OctoPrintSensorBase(CoordinatorEntity, SensorEntity): +class OctoPrintSensorBase( + CoordinatorEntity[OctoprintDataUpdateCoordinator], SensorEntity +): """Representation of an OctoPrint sensor.""" - coordinator: OctoprintDataUpdateCoordinator - def __init__( self, coordinator: OctoprintDataUpdateCoordinator, diff --git a/homeassistant/components/omnilogic/common.py b/homeassistant/components/omnilogic/common.py index 78685036e06..4c92420972b 100644 --- a/homeassistant/components/omnilogic/common.py +++ b/homeassistant/components/omnilogic/common.py @@ -73,7 +73,7 @@ class OmniLogicUpdateCoordinator(DataUpdateCoordinator): return parsed_data -class OmniLogicEntity(CoordinatorEntity): +class OmniLogicEntity(CoordinatorEntity[OmniLogicUpdateCoordinator]): """Defines the base OmniLogic entity.""" def __init__( diff --git a/homeassistant/components/open_meteo/weather.py b/homeassistant/components/open_meteo/weather.py index bb7170bb5da..40b52248a52 100644 --- a/homeassistant/components/open_meteo/weather.py +++ b/homeassistant/components/open_meteo/weather.py @@ -28,14 +28,18 @@ async def async_setup_entry( async_add_entities([OpenMeteoWeatherEntity(entry=entry, coordinator=coordinator)]) -class OpenMeteoWeatherEntity(CoordinatorEntity, WeatherEntity): +class OpenMeteoWeatherEntity( + CoordinatorEntity[DataUpdateCoordinator[OpenMeteoForecast]], WeatherEntity +): """Defines an Open-Meteo weather entity.""" _attr_temperature_unit = TEMP_CELSIUS - coordinator: DataUpdateCoordinator[OpenMeteoForecast] def __init__( - self, *, entry: ConfigEntry, coordinator: DataUpdateCoordinator + self, + *, + entry: ConfigEntry, + coordinator: DataUpdateCoordinator[OpenMeteoForecast], ) -> None: """Initialize Open-Meteo weather entity.""" super().__init__(coordinator=coordinator) diff --git a/homeassistant/components/overkiz/entity.py b/homeassistant/components/overkiz/entity.py index 72ef793c2b4..7c42f415a65 100644 --- a/homeassistant/components/overkiz/entity.py +++ b/homeassistant/components/overkiz/entity.py @@ -16,11 +16,9 @@ from .coordinator import OverkizDataUpdateCoordinator from .executor import OverkizExecutor -class OverkizEntity(CoordinatorEntity): +class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]): """Representation of an Overkiz device entity.""" - coordinator: OverkizDataUpdateCoordinator - def __init__( self, device_url: str, coordinator: OverkizDataUpdateCoordinator ) -> None: diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index edc076382ec..57f6b0ad99c 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -235,11 +235,11 @@ async def async_setup_entry( ) -class P1MonitorSensorEntity(CoordinatorEntity, SensorEntity): +class P1MonitorSensorEntity( + CoordinatorEntity[P1MonitorDataUpdateCoordinator], SensorEntity +): """Defines an P1 Monitor sensor.""" - coordinator: P1MonitorDataUpdateCoordinator - def __init__( self, *, diff --git a/homeassistant/components/philips_js/light.py b/homeassistant/components/philips_js/light.py index fc26fc3ed6a..21bb7199269 100644 --- a/homeassistant/components/philips_js/light.py +++ b/homeassistant/components/philips_js/light.py @@ -123,7 +123,9 @@ def _average_pixels(data): return 0.0, 0.0, 0.0 -class PhilipsTVLightEntity(CoordinatorEntity, LightEntity): +class PhilipsTVLightEntity( + CoordinatorEntity[PhilipsTVDataUpdateCoordinator], LightEntity +): """Representation of a Philips TV exposing the JointSpace API.""" def __init__( diff --git a/homeassistant/components/philips_js/media_player.py b/homeassistant/components/philips_js/media_player.py index 20fa2ced825..77a1d9dccd9 100644 --- a/homeassistant/components/philips_js/media_player.py +++ b/homeassistant/components/philips_js/media_player.py @@ -79,10 +79,11 @@ async def async_setup_entry( ) -class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity): +class PhilipsTVMediaPlayer( + CoordinatorEntity[PhilipsTVDataUpdateCoordinator], MediaPlayerEntity +): """Representation of a Philips TV exposing the JointSpace API.""" - coordinator: PhilipsTVDataUpdateCoordinator _attr_device_class = MediaPlayerDeviceClass.TV def __init__( diff --git a/homeassistant/components/philips_js/remote.py b/homeassistant/components/philips_js/remote.py index 09fe16215b6..38851964427 100644 --- a/homeassistant/components/philips_js/remote.py +++ b/homeassistant/components/philips_js/remote.py @@ -27,11 +27,9 @@ async def async_setup_entry( async_add_entities([PhilipsTVRemote(coordinator)]) -class PhilipsTVRemote(CoordinatorEntity, RemoteEntity): +class PhilipsTVRemote(CoordinatorEntity[PhilipsTVDataUpdateCoordinator], RemoteEntity): """Device that sends commands.""" - coordinator: PhilipsTVDataUpdateCoordinator - def __init__( self, coordinator: PhilipsTVDataUpdateCoordinator, diff --git a/homeassistant/components/philips_js/switch.py b/homeassistant/components/philips_js/switch.py index 15f72a8aaff..a89c22f1850 100644 --- a/homeassistant/components/philips_js/switch.py +++ b/homeassistant/components/philips_js/switch.py @@ -27,11 +27,11 @@ async def async_setup_entry( async_add_entities([PhilipsTVScreenSwitch(coordinator)]) -class PhilipsTVScreenSwitch(CoordinatorEntity, SwitchEntity): +class PhilipsTVScreenSwitch( + CoordinatorEntity[PhilipsTVDataUpdateCoordinator], SwitchEntity +): """A Philips TV screen state switch.""" - coordinator: PhilipsTVDataUpdateCoordinator - def __init__( self, coordinator: PhilipsTVDataUpdateCoordinator, diff --git a/homeassistant/components/pvoutput/sensor.py b/homeassistant/components/pvoutput/sensor.py index 471f4483a47..de108329c45 100644 --- a/homeassistant/components/pvoutput/sensor.py +++ b/homeassistant/components/pvoutput/sensor.py @@ -133,10 +133,11 @@ async def async_setup_entry( ) -class PVOutputSensorEntity(CoordinatorEntity, SensorEntity): +class PVOutputSensorEntity( + CoordinatorEntity[PVOutputDataUpdateCoordinator], SensorEntity +): """Representation of a PVOutput sensor.""" - coordinator: PVOutputDataUpdateCoordinator entity_description: PVOutputSensorEntityDescription def __init__( diff --git a/homeassistant/components/pvpc_hourly_pricing/sensor.py b/homeassistant/components/pvpc_hourly_pricing/sensor.py index 6d9ac9402e6..8cfae034bff 100644 --- a/homeassistant/components/pvpc_hourly_pricing/sensor.py +++ b/homeassistant/components/pvpc_hourly_pricing/sensor.py @@ -125,11 +125,9 @@ async def async_setup_entry( ) -class ElecPriceSensor(CoordinatorEntity, SensorEntity): +class ElecPriceSensor(CoordinatorEntity[ElecPricesDataUpdateCoordinator], SensorEntity): """Class to hold the prices of electricity as a sensor.""" - coordinator: ElecPricesDataUpdateCoordinator - def __init__( self, coordinator: ElecPricesDataUpdateCoordinator,