From 8df7291abb3bf42744c4baf597e93dbf335afb74 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 15 Nov 2023 06:31:10 +0100 Subject: [PATCH] Remove Withings entity descriptions required fields mixins (#104008) --- homeassistant/components/withings/sensor.py | 65 +++++---------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/homeassistant/components/withings/sensor.py b/homeassistant/components/withings/sensor.py index 707059a2930..b7ef6c6852b 100644 --- a/homeassistant/components/withings/sensor.py +++ b/homeassistant/components/withings/sensor.py @@ -58,20 +58,13 @@ from .coordinator import ( from .entity import WithingsEntity -@dataclass -class WithingsMeasurementSensorEntityDescriptionMixin: - """Mixin for describing withings data.""" +@dataclass(kw_only=True) +class WithingsMeasurementSensorEntityDescription(SensorEntityDescription): + """Immutable class for describing withings data.""" measurement_type: MeasurementType -@dataclass -class WithingsMeasurementSensorEntityDescription( - SensorEntityDescription, WithingsMeasurementSensorEntityDescriptionMixin -): - """Immutable class for describing withings data.""" - - MEASUREMENT_SENSORS: dict[ MeasurementType, WithingsMeasurementSensorEntityDescription ] = { @@ -243,20 +236,13 @@ MEASUREMENT_SENSORS: dict[ } -@dataclass -class WithingsSleepSensorEntityDescriptionMixin: - """Mixin for describing withings data.""" +@dataclass(kw_only=True) +class WithingsSleepSensorEntityDescription(SensorEntityDescription): + """Immutable class for describing withings data.""" value_fn: Callable[[SleepSummary], StateType] -@dataclass -class WithingsSleepSensorEntityDescription( - SensorEntityDescription, WithingsSleepSensorEntityDescriptionMixin -): - """Immutable class for describing withings data.""" - - SLEEP_SENSORS = [ WithingsSleepSensorEntityDescription( key="sleep_breathing_disturbances_intensity", @@ -410,20 +396,13 @@ SLEEP_SENSORS = [ ] -@dataclass -class WithingsActivitySensorEntityDescriptionMixin: - """Mixin for describing withings data.""" +@dataclass(kw_only=True) +class WithingsActivitySensorEntityDescription(SensorEntityDescription): + """Immutable class for describing withings data.""" value_fn: Callable[[Activity], StateType] -@dataclass -class WithingsActivitySensorEntityDescription( - SensorEntityDescription, WithingsActivitySensorEntityDescriptionMixin -): - """Immutable class for describing withings data.""" - - ACTIVITY_SENSORS = [ WithingsActivitySensorEntityDescription( key="activity_steps_today", @@ -514,20 +493,13 @@ SLEEP_GOAL = "sleep" WEIGHT_GOAL = "weight" -@dataclass -class WithingsGoalsSensorEntityDescriptionMixin: - """Mixin for describing withings data.""" +@dataclass(kw_only=True) +class WithingsGoalsSensorEntityDescription(SensorEntityDescription): + """Immutable class for describing withings data.""" value_fn: Callable[[Goals], StateType] -@dataclass -class WithingsGoalsSensorEntityDescription( - SensorEntityDescription, WithingsGoalsSensorEntityDescriptionMixin -): - """Immutable class for describing withings data.""" - - GOALS_SENSORS: dict[str, WithingsGoalsSensorEntityDescription] = { STEP_GOAL: WithingsGoalsSensorEntityDescription( key="step_goal", @@ -558,20 +530,13 @@ GOALS_SENSORS: dict[str, WithingsGoalsSensorEntityDescription] = { } -@dataclass -class WithingsWorkoutSensorEntityDescriptionMixin: - """Mixin for describing withings data.""" +@dataclass(kw_only=True) +class WithingsWorkoutSensorEntityDescription(SensorEntityDescription): + """Immutable class for describing withings data.""" value_fn: Callable[[Workout], StateType] -@dataclass -class WithingsWorkoutSensorEntityDescription( - SensorEntityDescription, WithingsWorkoutSensorEntityDescriptionMixin -): - """Immutable class for describing withings data.""" - - _WORKOUT_CATEGORY = [ workout_category.name.lower() for workout_category in WorkoutCategory ]