From 99de7a159f6c1c40040da89239c474c88325190b Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Sat, 6 Jul 2024 11:37:38 -0700 Subject: [PATCH] Lint fixes --- src/iaqualink/systems/exo/__init__.py | 2 +- src/iaqualink/systems/exo/device.py | 13 ++++++------- src/iaqualink/systems/exo/system.py | 15 ++++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/iaqualink/systems/exo/__init__.py b/src/iaqualink/systems/exo/__init__.py index ecfdf0e..6847ed0 100644 --- a/src/iaqualink/systems/exo/__init__.py +++ b/src/iaqualink/systems/exo/__init__.py @@ -1,3 +1,3 @@ -from . import device, system +from iaqualink.systems.exo import device, system __all__ = ["device", "system"] diff --git a/src/iaqualink/systems/exo/device.py b/src/iaqualink/systems/exo/device.py index 235be9a..5f10af2 100644 --- a/src/iaqualink/systems/exo/device.py +++ b/src/iaqualink/systems/exo/device.py @@ -1,9 +1,8 @@ from __future__ import annotations import logging -from collections.abc import Callable from enum import Enum, unique -from typing import TYPE_CHECKING, Any, Coroutine, Type, cast +from typing import TYPE_CHECKING, Any, cast from iaqualink.device import ( AqualinkDevice, @@ -12,10 +11,12 @@ AqualinkThermostat, ) from iaqualink.exception import AqualinkInvalidParameterException -from iaqualink.typing import DeviceData if TYPE_CHECKING: + from collections.abc import Callable, Coroutine + from iaqualink.systems.exo.system import ExoSystem + from iaqualink.typing import DeviceData EXO_TEMP_CELSIUS_LOW = 1 EXO_TEMP_CELSIUS_HIGH = 40 @@ -59,7 +60,7 @@ def model(self) -> str: @classmethod def from_data(cls, system: ExoSystem, data: DeviceData) -> ExoDevice: - class_: Type[ExoDevice] + class_: type[ExoDevice] if data["name"].startswith("aux_"): class_ = ExoAuxSwitch @@ -94,7 +95,7 @@ def label(self) -> str: @property def name(self) -> str: - # XXX - We're using the label as name rather than "sns_#". + # XXX: We're using the label as name rather than "sns_#". # Might revisit later. return self.data["sensor_type"].lower().replace(" ", "_") @@ -102,8 +103,6 @@ def name(self) -> str: class ExoAttributeSensor(ExoDevice, AqualinkSensor): """These sensors are a simple key/value in equipment->swc_0.""" - pass - # This is an abstract class, not to be instantiated directly. class ExoSwitch(ExoDevice, AqualinkSwitch): diff --git a/src/iaqualink/systems/exo/system.py b/src/iaqualink/systems/exo/system.py index 22ebba0..d0db405 100644 --- a/src/iaqualink/systems/exo/system.py +++ b/src/iaqualink/systems/exo/system.py @@ -2,9 +2,7 @@ import logging import time -from typing import TYPE_CHECKING, Any, Dict - -import httpx +from typing import TYPE_CHECKING, Any from iaqualink.const import MIN_SECS_TO_REFRESH from iaqualink.exception import ( @@ -13,10 +11,12 @@ ) from iaqualink.system import AqualinkSystem from iaqualink.systems.exo.device import ExoDevice -from iaqualink.typing import Payload if TYPE_CHECKING: + import httpx + from iaqualink.client import AqualinkClient + from iaqualink.typing import Payload EXO_DEVICES_URL = "https://prod.zodiac-io.com/devices/v1" @@ -29,10 +29,12 @@ class ExoSystem(AqualinkSystem): def __init__(self, aqualink: AqualinkClient, data: Payload): super().__init__(aqualink, data) + # This lives in the parent class but mypy complains. + self.last_refresh: int = 0 def __repr__(self) -> str: attrs = ["name", "serial", "data"] - attrs = ["%s=%r" % (i, getattr(self, i)) for i in attrs] + attrs = [f"{i}={getattr(self, i)!r}" for i in attrs] return f'{self.__class__.__name__}({" ".join(attrs)})' async def send_devices_request(self, **kwargs: Any) -> httpx.Response: @@ -44,7 +46,7 @@ async def send_reported_state_request(self) -> httpx.Response: return await self.send_devices_request() async def send_desired_state_request( - self, state: Dict[str, Any] + self, state: dict[str, Any] ) -> httpx.Response: return await self.send_devices_request( method="post", json={"state": {"desired": state}} @@ -103,7 +105,6 @@ def _parse_shadow_response(self, response: httpx.Response) -> None: devices.update({name: attrs}) LOGGER.debug(f"devices: {devices}") - print(devices) for k, v in devices.items(): if k in self.devices: