From d2aa63364865580cf10c85fdb501139cd4727daa Mon Sep 17 00:00:00 2001 From: "mike.toggweiler" Date: Tue, 19 Nov 2024 08:14:12 +0100 Subject: [PATCH] fixed linter issues --- custom_components/askoheat/api.py | 2 +- custom_components/askoheat/api_desc.py | 14 ++++++++------ custom_components/askoheat/entity.py | 8 ++++---- custom_components/askoheat/select.py | 2 +- custom_components/askoheat/text.py | 2 -- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/custom_components/askoheat/api.py b/custom_components/askoheat/api.py index 8b0f402..644baff 100644 --- a/custom_components/askoheat/api.py +++ b/custom_components/askoheat/api.py @@ -437,7 +437,7 @@ def _prepare_str(value: object) -> list[int]: byte_list = str_value.encode("utf-8") size = int(len(byte_list) / 2) result = [] - for index in range(0, size): + for index in range(size): b = byte_list[index * 2 : index * 2 + 1] result.append(int.from_bytes(b, "little")) return result diff --git a/custom_components/askoheat/api_desc.py b/custom_components/askoheat/api_desc.py index 7e59036..5e63feb 100644 --- a/custom_components/askoheat/api_desc.py +++ b/custom_components/askoheat/api_desc.py @@ -6,19 +6,21 @@ from abc import ABC from dataclasses import dataclass, field from enum import IntEnum, StrEnum -from typing import TYPE_CHECKING, Callable, TypeVar - -import numpy +from typing import TYPE_CHECKING, TypeVar if TYPE_CHECKING: + from collections.abc import Callable + + import numpy as np + from custom_components.askoheat.model import ( AskoheatBinarySensorEntityDescription, AskoheatNumberEntityDescription, + AskoheatSelectEntityDescription, AskoheatSensorEntityDescription, AskoheatSwitchEntityDescription, - AskoheatTimeEntityDescription, - AskoheatSelectEntityDescription, AskoheatTextEntityDescription, + AskoheatTimeEntityDescription, ) @@ -90,7 +92,7 @@ class StrEnumInputDescriptor[E](StringRegisterInputDescriptor): class IntEnumInputDescriptor[E2](ByteRegisterInputDescriptor): """Input register representing a int based enum value.""" - factory: Callable[[numpy.byte], E2] + factory: Callable[[np.byte], E2] values: list[E2] diff --git a/custom_components/askoheat/entity.py b/custom_components/askoheat/entity.py index 3abd1c2..538835c 100644 --- a/custom_components/askoheat/entity.py +++ b/custom_components/askoheat/entity.py @@ -40,7 +40,7 @@ def __init__( ) self.entity_description = entity_description self.translation_key = ( - entity_description.translation_key or entity_description.key.value # type: ignore + entity_description.translation_key or entity_description.key.value # type: ignore # noqa: PGH003 ) async def async_added_to_hass(self) -> None: @@ -61,10 +61,10 @@ def _handle_coordinator_update(self) -> None: icon_state = self._attr_state if hasattr(self, "_attr_is_on"): icon_state = self._attr_is_on # type: ignore # noqa: PGH003 - if descr.icon_by_state is not None and icon_state in descr.icon_by_state: # type: ignore - self._attr_icon = descr.icon_by_state.get(icon_state) # type: ignore + if descr.icon_by_state is not None and icon_state in descr.icon_by_state: # type: ignore # noqa: PGH003 + self._attr_icon = descr.icon_by_state.get(icon_state) # type: ignore # noqa: PGH003 else: - self._attr_icon = descr.icon # type: ignore + self._attr_icon = descr.icon # type: ignore # noqa: PGH003 super()._handle_coordinator_update() self.async_write_ha_state() diff --git a/custom_components/askoheat/select.py b/custom_components/askoheat/select.py index b4c0040..bd989fb 100644 --- a/custom_components/askoheat/select.py +++ b/custom_components/askoheat/select.py @@ -1,7 +1,7 @@ """Askoheat time entity.""" from functools import cached_property -import platform + from homeassistant.components.select import ENTITY_ID_FORMAT, SelectEntity from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback diff --git a/custom_components/askoheat/text.py b/custom_components/askoheat/text.py index ff80a99..1d9b809 100644 --- a/custom_components/askoheat/text.py +++ b/custom_components/askoheat/text.py @@ -1,6 +1,5 @@ """Askoheat time entity.""" -from datetime import time from homeassistant.components.text import ENTITY_ID_FORMAT, TextEntity from homeassistant.core import HomeAssistant, callback @@ -12,7 +11,6 @@ from custom_components.askoheat.coordinator import AskoheatDataUpdateCoordinator from custom_components.askoheat.model import ( AskoheatTextEntityDescription, - AskoheatTimeEntityDescription, ) from .data import AskoheatConfigEntry