From 2c003d8c105bb044d6847f03598b64ca2ffcac8c Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 16 Nov 2023 16:05:29 +0100 Subject: [PATCH] Remove Deconz entity descriptions required fields mixins (#104009) --- .../components/deconz/binary_sensor.py | 17 ++++------------- homeassistant/components/deconz/button.py | 15 +++++---------- homeassistant/components/deconz/number.py | 11 +++-------- homeassistant/components/deconz/sensor.py | 16 +++++----------- 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/homeassistant/components/deconz/binary_sensor.py b/homeassistant/components/deconz/binary_sensor.py index 114e401346d..84141eac964 100644 --- a/homeassistant/components/deconz/binary_sensor.py +++ b/homeassistant/components/deconz/binary_sensor.py @@ -65,24 +65,15 @@ T = TypeVar( ) -@dataclass -class DeconzBinarySensorDescriptionMixin(Generic[T]): - """Required values when describing secondary sensor attributes.""" - - update_key: str - value_fn: Callable[[T], bool | None] - - -@dataclass -class DeconzBinarySensorDescription( - BinarySensorEntityDescription, - DeconzBinarySensorDescriptionMixin[T], -): +@dataclass(kw_only=True) +class DeconzBinarySensorDescription(Generic[T], BinarySensorEntityDescription): """Class describing deCONZ binary sensor entities.""" instance_check: type[T] | None = None name_suffix: str = "" old_unique_id_suffix: str = "" + update_key: str + value_fn: Callable[[T], bool | None] ENTITY_DESCRIPTIONS: tuple[DeconzBinarySensorDescription, ...] = ( diff --git a/homeassistant/components/deconz/button.py b/homeassistant/components/deconz/button.py index 318e0e43beb..81d839ea0f2 100644 --- a/homeassistant/components/deconz/button.py +++ b/homeassistant/components/deconz/button.py @@ -23,18 +23,13 @@ from .deconz_device import DeconzDevice, DeconzSceneMixin from .gateway import DeconzGateway, get_gateway_from_config_entry -@dataclass -class DeconzButtonDescriptionMixin: - """Required values when describing deCONZ button entities.""" - - suffix: str - button_fn: str - - -@dataclass -class DeconzButtonDescription(ButtonEntityDescription, DeconzButtonDescriptionMixin): +@dataclass(kw_only=True) +class DeconzButtonDescription(ButtonEntityDescription): """Class describing deCONZ button entities.""" + button_fn: str + suffix: str + ENTITY_DESCRIPTIONS = { PydeconzScene: [ diff --git a/homeassistant/components/deconz/number.py b/homeassistant/components/deconz/number.py index ec4438502b6..7cc0da936cb 100644 --- a/homeassistant/components/deconz/number.py +++ b/homeassistant/components/deconz/number.py @@ -31,9 +31,9 @@ from .util import serial_from_unique_id T = TypeVar("T", Presence, PydeconzSensorBase) -@dataclass -class DeconzNumberDescriptionMixin(Generic[T]): - """Required values when describing deCONZ number entities.""" +@dataclass(kw_only=True) +class DeconzNumberDescription(Generic[T], NumberEntityDescription): + """Class describing deCONZ number entities.""" instance_check: type[T] name_suffix: str @@ -42,11 +42,6 @@ class DeconzNumberDescriptionMixin(Generic[T]): value_fn: Callable[[T], float | None] -@dataclass -class DeconzNumberDescription(NumberEntityDescription, DeconzNumberDescriptionMixin[T]): - """Class describing deCONZ number entities.""" - - ENTITY_DESCRIPTIONS: tuple[DeconzNumberDescription, ...] = ( DeconzNumberDescription[Presence]( key="delay", diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index 4e00ac0a415..a635a784676 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -91,22 +91,16 @@ T = TypeVar( ) -@dataclass -class DeconzSensorDescriptionMixin(Generic[T]): - """Required values when describing secondary sensor attributes.""" - - supported_fn: Callable[[T], bool] - update_key: str - value_fn: Callable[[T], datetime | StateType] - - -@dataclass -class DeconzSensorDescription(SensorEntityDescription, DeconzSensorDescriptionMixin[T]): +@dataclass(kw_only=True) +class DeconzSensorDescription(Generic[T], SensorEntityDescription): """Class describing deCONZ binary sensor entities.""" instance_check: type[T] | None = None name_suffix: str = "" old_unique_id_suffix: str = "" + supported_fn: Callable[[T], bool] + update_key: str + value_fn: Callable[[T], datetime | StateType] ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (