From 62817ba3383e3cd16efe613403c620f4a9b0bb45 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 11 Mar 2024 12:05:55 +0100 Subject: [PATCH] Remove entity description mixin in Melnor (#112906) --- homeassistant/components/melnor/number.py | 13 +++--------- homeassistant/components/melnor/sensor.py | 26 ++++++----------------- homeassistant/components/melnor/switch.py | 13 +++--------- homeassistant/components/melnor/time.py | 13 +++--------- 4 files changed, 15 insertions(+), 50 deletions(-) diff --git a/homeassistant/components/melnor/number.py b/homeassistant/components/melnor/number.py index f68cdd1b29e..33d9fa443b1 100644 --- a/homeassistant/components/melnor/number.py +++ b/homeassistant/components/melnor/number.py @@ -26,21 +26,14 @@ from .models import ( ) -@dataclass(frozen=True) -class MelnorZoneNumberEntityDescriptionMixin: - """Mixin for required keys.""" +@dataclass(frozen=True, kw_only=True) +class MelnorZoneNumberEntityDescription(NumberEntityDescription): + """Describes Melnor number entity.""" set_num_fn: Callable[[Valve, int], Coroutine[Any, Any, None]] state_fn: Callable[[Valve], Any] -@dataclass(frozen=True) -class MelnorZoneNumberEntityDescription( - NumberEntityDescription, MelnorZoneNumberEntityDescriptionMixin -): - """Describes Melnor number entity.""" - - ZONE_ENTITY_DESCRIPTIONS: list[MelnorZoneNumberEntityDescription] = [ MelnorZoneNumberEntityDescription( entity_category=EntityCategory.CONFIG, diff --git a/homeassistant/components/melnor/sensor.py b/homeassistant/components/melnor/sensor.py index 8765cd538f8..6528773d9d8 100644 --- a/homeassistant/components/melnor/sensor.py +++ b/homeassistant/components/melnor/sensor.py @@ -55,32 +55,18 @@ def next_cycle(valve: Valve) -> datetime | None: return None -@dataclass(frozen=True) -class MelnorSensorEntityDescriptionMixin: - """Mixin for required keys.""" - - state_fn: Callable[[Device], Any] - - -@dataclass(frozen=True) -class MelnorZoneSensorEntityDescriptionMixin: - """Mixin for required keys.""" +@dataclass(frozen=True, kw_only=True) +class MelnorZoneSensorEntityDescription(SensorEntityDescription): + """Describes Melnor sensor entity.""" state_fn: Callable[[Valve], Any] -@dataclass(frozen=True) -class MelnorZoneSensorEntityDescription( - SensorEntityDescription, MelnorZoneSensorEntityDescriptionMixin -): +@dataclass(frozen=True, kw_only=True) +class MelnorSensorEntityDescription(SensorEntityDescription): """Describes Melnor sensor entity.""" - -@dataclass(frozen=True) -class MelnorSensorEntityDescription( - SensorEntityDescription, MelnorSensorEntityDescriptionMixin -): - """Describes Melnor sensor entity.""" + state_fn: Callable[[Device], Any] DEVICE_ENTITY_DESCRIPTIONS: list[MelnorSensorEntityDescription] = [ diff --git a/homeassistant/components/melnor/switch.py b/homeassistant/components/melnor/switch.py index 48b9a65e920..f912db1e981 100644 --- a/homeassistant/components/melnor/switch.py +++ b/homeassistant/components/melnor/switch.py @@ -25,21 +25,14 @@ from .models import ( ) -@dataclass(frozen=True) -class MelnorSwitchEntityDescriptionMixin: - """Mixin for required keys.""" +@dataclass(frozen=True, kw_only=True) +class MelnorSwitchEntityDescription(SwitchEntityDescription): + """Describes Melnor switch entity.""" on_off_fn: Callable[[Valve, bool], Coroutine[Any, Any, None]] state_fn: Callable[[Valve], Any] -@dataclass(frozen=True) -class MelnorSwitchEntityDescription( - SwitchEntityDescription, MelnorSwitchEntityDescriptionMixin -): - """Describes Melnor switch entity.""" - - ZONE_ENTITY_DESCRIPTIONS = [ MelnorSwitchEntityDescription( device_class=SwitchDeviceClass.SWITCH, diff --git a/homeassistant/components/melnor/time.py b/homeassistant/components/melnor/time.py index 36afe2d976d..d2d05f6517f 100644 --- a/homeassistant/components/melnor/time.py +++ b/homeassistant/components/melnor/time.py @@ -23,21 +23,14 @@ from .models import ( ) -@dataclass(frozen=True) -class MelnorZoneTimeEntityDescriptionMixin: - """Mixin for required keys.""" +@dataclass(frozen=True, kw_only=True) +class MelnorZoneTimeEntityDescription(TimeEntityDescription): + """Describes Melnor number entity.""" set_time_fn: Callable[[Valve, time], Coroutine[Any, Any, None]] state_fn: Callable[[Valve], Any] -@dataclass(frozen=True) -class MelnorZoneTimeEntityDescription( - TimeEntityDescription, MelnorZoneTimeEntityDescriptionMixin -): - """Describes Melnor number entity.""" - - ZONE_ENTITY_DESCRIPTIONS: list[MelnorZoneTimeEntityDescription] = [ MelnorZoneTimeEntityDescription( entity_category=EntityCategory.CONFIG,