From ed3f25489e4bae23cd91bf5b6c23b23fd5e557f5 Mon Sep 17 00:00:00 2001 From: Eugene Prystupa Date: Mon, 13 Jul 2020 17:07:35 -0400 Subject: [PATCH] Apply bond python related feedback from a prior PR (#37821) --- homeassistant/components/bond/utils.py | 32 +++++++++++--------------- tests/components/bond/test_cover.py | 2 +- tests/components/bond/test_fan.py | 2 +- tests/components/bond/test_light.py | 2 +- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/bond/utils.py b/homeassistant/components/bond/utils.py index a8636d638cb..d9fcd9b05d6 100644 --- a/homeassistant/components/bond/utils.py +++ b/homeassistant/components/bond/utils.py @@ -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] + ] ) diff --git a/tests/components/bond/test_cover.py b/tests/components/bond/test_cover.py index 695c5410247..9e1f87e8c0d 100644 --- a/tests/components/bond/test_cover.py +++ b/tests/components/bond/test_cover.py @@ -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): diff --git a/tests/components/bond/test_fan.py b/tests/components/bond/test_fan.py index 4eb11521bfb..f762b4942d1 100644 --- a/tests/components/bond/test_fan.py +++ b/tests/components/bond/test_fan.py @@ -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): diff --git a/tests/components/bond/test_light.py b/tests/components/bond/test_light.py index 4e0ea6155fb..66393151b4f 100644 --- a/tests/components/bond/test_light.py +++ b/tests/components/bond/test_light.py @@ -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):