Skip to content

Commit d41b43b

Browse files
committed
chore: Remove use of decorator and replace with class attribute
1 parent 90efc95 commit d41b43b

File tree

5 files changed

+4
-30
lines changed

5 files changed

+4
-30
lines changed

roborock/devices/traits/v1/child_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
_STATUS_PARAM = "lock_status"
66

77

8-
@common.requires_feature("is_set_child_supported")
98
class ChildLockTrait(ChildLockStatus, common.V1TraitMixin):
109
"""Trait for controlling the child lock of a Roborock device."""
1110

1211
command = RoborockCommand.GET_CHILD_LOCK_STATUS
12+
requires_feature = "is_set_child_supported"
1313

1414
async def enable(self) -> None:
1515
"""Enable the child lock."""

roborock/devices/traits/v1/common.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -147,29 +147,3 @@ def wrapper(*args, **kwargs):
147147

148148
cls.map_rpc_channel = True # type: ignore[attr-defined]
149149
return wrapper
150-
151-
152-
def requires_feature(feature_attribute_name: str):
153-
"""Decorator to mark a trait as requiring a specific device feature.
154-
155-
This decorator marks a trait class as requiring a specific device feature
156-
to be supported. The feature check should be a direct reference to a
157-
DeviceFeatures attribute.
158-
159-
Args:
160-
feature_attribute: Direct reference to the DeviceFeatures attribute
161-
(e.g., DeviceFeatures.is_set_child_supported)
162-
163-
Example:
164-
@requires_feature("is_flow_led_setting_supported")
165-
class FlowLedStatusTrait(FlowLedStatus, V1TraitMixin):
166-
...
167-
"""
168-
169-
def decorator(cls):
170-
class Wrapper(cls): # type: ignore[valid-type, misc]
171-
requires_feature = feature_attribute_name # type: ignore[attr-defined]
172-
173-
return Wrapper
174-
175-
return decorator

roborock/devices/traits/v1/flow_led_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
_STATUS_PARAM = "status"
66

77

8-
@common.requires_feature("is_flow_led_setting_supported")
98
class FlowLedStatusTrait(FlowLedStatus, common.V1TraitMixin):
109
"""Trait for controlling the Flow LED status of a Roborock device."""
1110

1211
command = RoborockCommand.GET_FLOW_LED_STATUS
12+
requires_feature = "is_flow_led_setting_supported"
1313

1414
async def enable(self) -> None:
1515
"""Enable the Flow LED status."""

roborock/devices/traits/v1/led_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from .common import V1ResponseData
66

77

8-
@common.requires_feature("is_led_status_switch_supported")
98
class LedStatusTrait(LedStatus, common.V1TraitMixin):
109
"""Trait for controlling the LED status of a Roborock device."""
1110

1211
command = RoborockCommand.GET_LED_STATUS
12+
requires_feature = "is_led_status_switch_supported"
1313

1414
async def enable(self) -> None:
1515
"""Enable the LED status."""

roborock/devices/traits/v1/valley_electricity_timer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
_ENABLED_PARAM = "enabled"
66

77

8-
@common.requires_feature("is_supported_valley_electricity")
98
class ValleyElectricityTimerTrait(ValleyElectricityTimer, common.V1TraitMixin):
109
"""Trait for managing Valley Electricity Timer settings on Roborock devices."""
1110

1211
command = RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER
12+
requires_feature = "is_supported_valley_electricity"
1313

1414
async def set_timer(self, timer: ValleyElectricityTimer) -> None:
1515
"""Set the Valley Electricity Timer settings of the device."""

0 commit comments

Comments
 (0)