From c692d3150f9db3f387175a0274d6633173dcf553 Mon Sep 17 00:00:00 2001 From: IceBotYT <34712694+IceBotYT@users.noreply.github.com> Date: Tue, 25 Apr 2023 23:30:48 +0000 Subject: [PATCH] Minor refactoring --- .../components/linear_garage_door/cover.py | 33 +++++++++---------- .../linear_garage_door/diagnostics.py | 4 +-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/linear_garage_door/cover.py b/homeassistant/components/linear_garage_door/cover.py index 8827af09545b4a..1b0f83ee6f1174 100644 --- a/homeassistant/components/linear_garage_door/cover.py +++ b/homeassistant/components/linear_garage_door/cover.py @@ -34,21 +34,20 @@ async def async_setup_entry( coordinator: LinearUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] data = coordinator.data - device_list = [] + device_list: list[LinearCoverEntity] = [] for device_id in data: - for subdev in data[device_id]["subdevices"]: - if subdev in SUPPORTED_SUBDEVICES: - device_list.append( - LinearCoverEntity( - device_id=device_id, - device_name=data[device_id]["name"], - subdevice=subdev, - config_entry=config_entry, - coordinator=coordinator, - ) - ) - + device_list.extend( + LinearCoverEntity( + device_id=device_id, + device_name=data[device_id]["name"], + subdevice=subdev, + config_entry=config_entry, + coordinator=coordinator, + ) + for subdev in data[device_id]["subdevices"] + if subdev in SUPPORTED_SUBDEVICES + ) async_add_entities(device_list) @@ -88,7 +87,7 @@ def device_info(self) -> DeviceInfo: ) @property - def is_closed(self) -> bool: + def is_closed(self) -> bool: # sourcery skip: remove-unnecessary-cast """Return if cover is closed.""" return bool( self.coordinator.data[self._device_id]["subdevices"][self._subdevice][ @@ -98,7 +97,7 @@ def is_closed(self) -> bool: ) @property - def is_opened(self) -> bool: + def is_opened(self) -> bool: # sourcery skip: remove-unnecessary-cast """Return if cover is open.""" return bool( self.coordinator.data[self._device_id]["subdevices"][self._subdevice][ @@ -108,7 +107,7 @@ def is_opened(self) -> bool: ) @property - def is_opening(self) -> bool: + def is_opening(self) -> bool: # sourcery skip: remove-unnecessary-cast """Return if cover is opening.""" return bool( self.coordinator.data[self._device_id]["subdevices"][self._subdevice].get( @@ -118,7 +117,7 @@ def is_opening(self) -> bool: ) @property - def is_closing(self) -> bool: + def is_closing(self) -> bool: # sourcery skip: remove-unnecessary-cast """Return if cover is closing.""" return bool( self.coordinator.data[self._device_id]["subdevices"][self._subdevice].get( diff --git a/homeassistant/components/linear_garage_door/diagnostics.py b/homeassistant/components/linear_garage_door/diagnostics.py index a91efee8188da8..fffcdd7de871c9 100644 --- a/homeassistant/components/linear_garage_door/diagnostics.py +++ b/homeassistant/components/linear_garage_door/diagnostics.py @@ -20,9 +20,7 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: LinearUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] - diag_data = { + return { "entry": async_redact_data(entry.as_dict(), TO_REDACT), "coordinator_data": coordinator.data, } - - return diag_data