Skip to content

Commit

Permalink
Apply bond python related feedback from a prior PR (home-assistant#37821
Browse files Browse the repository at this point in the history
)
  • Loading branch information
prystupa authored Jul 13, 2020
1 parent 4aaf7c5 commit ed3f254
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
32 changes: 13 additions & 19 deletions homeassistant/components/bond/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,28 @@ def type(self) -> str:
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]
]
)


Expand Down
2 changes: 1 addition & 1 deletion tests/components/bond/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def test_entity_registry(hass: core.HomeAssistant):
await setup_platform(hass, COVER_DOMAIN, shades("name-1"))

registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry()
assert [key for key in registry.entities.keys()] == ["cover.name_1"]
assert [key for key in registry.entities] == ["cover.name_1"]


async def test_open_cover(hass: core.HomeAssistant):
Expand Down
2 changes: 1 addition & 1 deletion tests/components/bond/test_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def test_entity_registry(hass: core.HomeAssistant):
await setup_platform(hass, FAN_DOMAIN, ceiling_fan("name-1"))

registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry()
assert [key for key in registry.entities.keys()] == ["fan.name_1"]
assert [key for key in registry.entities] == ["fan.name_1"]


async def test_turn_on_fan(hass: core.HomeAssistant):
Expand Down
2 changes: 1 addition & 1 deletion tests/components/bond/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def test_entity_registry(hass: core.HomeAssistant):
await setup_platform(hass, LIGHT_DOMAIN, ceiling_fan("name-1"))

registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry()
assert [key for key in registry.entities.keys()] == ["light.name_1"]
assert [key for key in registry.entities] == ["light.name_1"]


async def test_turn_on_light(hass: core.HomeAssistant):
Expand Down

0 comments on commit ed3f254

Please sign in to comment.