Apply bond python related feedback from a prior PR (#37821)

This commit is contained in:
Eugene Prystupa authored and GitHub committed 2020-07-13 23:07:35 +02:00
1 parent 4aaf7c5432
commit ed3f25489e
4 files changed
+16 -22

No files matched your search

+13 -19
View File
@@ -26,34 +26,28 @@ class BondDevice:
def supports_speed(self) -> bool:
"""Return True if this device supports any of the speed related commands."""
actions: List[str] = self._attrs["actions"]
return len([action for action in actions if action in [Actions.SET_SPEED]]) > 0
return bool([action for action in actions if action in [Actions.SET_SPEED]])
def supports_direction(self) -> bool:
"""Return True if this device supports any of the direction related commands."""
actions: List[str] = self._attrs["actions"]
return (
len(
[
action
for action in actions
if action in [Actions.SET_DIRECTION, Actions.TOGGLE_DIRECTION]
]
)
> 0
return bool(
[
action
for action in actions
if action in [Actions.SET_DIRECTION, Actions.TOGGLE_DIRECTION]
]
)
def supports_light(self) -> bool:
"""Return True if this device supports any of the light related commands."""
actions: List[str] = self._attrs["actions"]
return (
len(
[
action
for action in actions
if action in [Actions.TURN_LIGHT_ON, Actions.TOGGLE_LIGHT]
]
)
> 0
return bool(
[
action
for action in actions
if action in [Actions.TURN_LIGHT_ON, Actions.TOGGLE_LIGHT]
]
)