From 98ddaefa11eafb2e5208a5222db6eb8dea7d0eb7 Mon Sep 17 00:00:00 2001 From: RogerSelwyn Date: Mon, 16 Dec 2024 13:13:12 +0000 Subject: [PATCH] maint: Remove linting errors --- custom_components/homelink/binary_sensor.py | 18 +++++++++--------- custom_components/homelink/config_flow.py | 6 +++--- custom_components/homelink/event.py | 6 ++---- .../homelink/helpers/coordinator.py | 4 ++-- custom_components/homelink/helpers/entity.py | 3 +-- custom_components/homelink/sensor.py | 2 +- tests/helpers/utils.py | 6 +++--- 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/custom_components/homelink/binary_sensor.py b/custom_components/homelink/binary_sensor.py index c2414da..5bf44b3 100644 --- a/custom_components/homelink/binary_sensor.py +++ b/custom_components/homelink/binary_sensor.py @@ -1,7 +1,7 @@ """Support for HomeLINK sensors.""" from collections.abc import Callable -from typing import Any, List +from typing import Any from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, @@ -270,10 +270,10 @@ def __init__( alarm_type: str, ) -> None: """Property entity object for HomeLINK sensor.""" - self._alerts: List[dict] = [] + self._alerts: list[dict] = [] self._status: bool | None = None - self._alarms_devices: List[str | None] | str = [] - self._alarms_rooms: List[str | None] | str = [] + self._alarms_devices: list[str | None] | str = [] + self._alarms_rooms: list[str | None] | str = [] self._dev_reg = device_registry.async_get(hass) super().__init__(coordinator, hl_property_key, alarm_type) self._entry = entry @@ -375,7 +375,7 @@ def _set_status(self) -> tuple[bool, list[str | None] | str, list[Any] | str]: alarms_rooms or ALARMS_NONE, ) - def _set_alerts(self) -> List[dict]: + def _set_alerts(self) -> list[dict]: # Alerts relate to devices on than environment sensor # so there is no location return [ @@ -393,7 +393,7 @@ def _set_alerts(self) -> List[dict]: if not alert.location ] - def _get_alerts(self) -> List[Alert]: + def _get_alerts(self) -> list[Alert]: # Retrieve the alert if: # - Device is environment and the alert is and insight # - Device is alarm and alert is not environment and not an insight @@ -463,7 +463,7 @@ def __init__( device_key: str, ) -> None: """Device entity object for HomeLINK sensor.""" - self._alerts: List[dict] = [] + self._alerts: list[dict] = [] super().__init__(coordinator, hl_property_key, device_key) self._entry = entry @@ -576,7 +576,7 @@ def _is_data_in_coordinator(self) -> bool: def _set_status(self) -> bool: return bool(self._get_alerts()) - def _set_alerts(self) -> List[dict]: + def _set_alerts(self) -> list[dict]: alerts = self._get_alerts() return [ { @@ -592,7 +592,7 @@ def _set_alerts(self) -> List[dict]: for alert in alerts ] - def _get_alerts(self) -> List[Alert]: + def _get_alerts(self) -> list[Alert]: # Retrieve the alert if: # - The alert is a device and is for the entity device # - The alert location is entity location and there is no serialnumber diff --git a/custom_components/homelink/config_flow.py b/custom_components/homelink/config_flow.py index 5fd56ec..ff67e0c 100644 --- a/custom_components/homelink/config_flow.py +++ b/custom_components/homelink/config_flow.py @@ -7,7 +7,7 @@ import time from collections.abc import Mapping from copy import deepcopy -from typing import Any, List, Self +from typing import Any, Self import aiohttp import homeassistant.helpers.config_validation as cv @@ -173,7 +173,7 @@ def __init__(self, config_entry: ConfigEntry): self._webhook_id = options.get(CONF_WEBHOOK_ID, None) self._user_input: dict[str, Any] | None = None self._webhook_displayed = False - self._property_list: List[str] = [] + self._property_list: list[str] = [] async def async_step_init( self, @@ -264,7 +264,7 @@ async def async_step_user( errors=errors, ) - async def _async_get_properties(self) -> List[str]: + async def _async_get_properties(self) -> list[str]: # Perform authentication and fail if not possible # Then retrieve the property list implementation = ( diff --git a/custom_components/homelink/event.py b/custom_components/homelink/event.py index f3452f3..617335d 100644 --- a/custom_components/homelink/event.py +++ b/custom_components/homelink/event.py @@ -1,7 +1,5 @@ """Support for HomeLINK events.""" -from typing import List - from homeassistant.components.event import DOMAIN as EVENT_DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback @@ -126,7 +124,7 @@ class HomeLINKPropertyEvent(HomeLINKEventEntity): """Event entity for HomeLINK Property.""" def __init__( - self, entry: HLConfigEntry, hl_property_key: str, eventtypes: List[str] + self, entry: HLConfigEntry, hl_property_key: str, eventtypes: list[str] ) -> None: """Property event entity object for HomeLINK sensor.""" super().__init__(entry, hl_property_key, eventtypes, hl_property_key) @@ -147,7 +145,7 @@ def __init__( device_key: str, device: Device, gateway_key: str, - eventtypes: List[str], + eventtypes: list[str], ) -> None: """Device event entity object for HomeLINK sensor.""" mqtt_key = build_mqtt_device_key(device, device_key, gateway_key) diff --git a/custom_components/homelink/helpers/coordinator.py b/custom_components/homelink/helpers/coordinator.py index 0c936eb..4903653 100644 --- a/custom_components/homelink/helpers/coordinator.py +++ b/custom_components/homelink/helpers/coordinator.py @@ -5,7 +5,7 @@ import traceback from copy import deepcopy from datetime import date, datetime, timedelta -from typing import Any, List +from typing import Any from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -190,7 +190,7 @@ async def _async_get_core_data(self) -> Any: async def _async_retrieve_readings( self, hl_property: Property, property_devices: dict[str, Device] - ) -> List[PropertyReading]: + ) -> list[PropertyReading]: readings = [] for device in property_devices.values(): if hasattr(device.rel, ATTR_READINGS): diff --git a/custom_components/homelink/helpers/entity.py b/custom_components/homelink/helpers/entity.py index b52b85b..f33d4d3 100644 --- a/custom_components/homelink/helpers/entity.py +++ b/custom_components/homelink/helpers/entity.py @@ -2,7 +2,6 @@ from abc import abstractmethod from collections.abc import Callable -from typing import List from homeassistant.components.event import EventEntity from homeassistant.core import callback @@ -147,7 +146,7 @@ class HomeLINKEventEntity(EventEntity): _attr_should_poll = False def __init__( - self, entry: HLConfigEntry, key: str, eventtypes: List[str], mqtt_key: str + self, entry: HLConfigEntry, key: str, eventtypes: list[str], mqtt_key: str ) -> None: """Property event entity object for HomeLINK sensor.""" self._key = key diff --git a/custom_components/homelink/sensor.py b/custom_components/homelink/sensor.py index eb0a14a..427d05e 100644 --- a/custom_components/homelink/sensor.py +++ b/custom_components/homelink/sensor.py @@ -418,7 +418,7 @@ async def _async_message_handle( class HomeLINKEnergyReadingSensor(HomeLINKReadingSensor): - """An energy Reading Sensor""" + """An energy Reading Sensor.""" @property def translation_key(self) -> str: diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py index 99d5ce5..d2a8bcb 100644 --- a/tests/helpers/utils.py +++ b/tests/helpers/utils.py @@ -17,9 +17,9 @@ def check_entity_state( ): """Check entity state.""" state = hass.states.get(entity_name) - print("*************************** State") - print(state.state) - print(state.attributes) + # print("*************************** State") + # print(state.state) + # print(state.attributes) assert state.state == entity_state if entity_attributes: # print("*************************** State Attributes")