Enable ruff check for ANN (#1139)

This commit is contained in:
Teemu R.
2024-11-10 19:55:13 +01:00
committed by GitHub
parent 6b44fe6242
commit 66eb17057e
89 changed files with 596 additions and 452 deletions

View File

@@ -49,14 +49,14 @@ class UpdateInfo(BaseModel):
needs_upgrade: bool = Field(alias="need_to_upgrade")
@validator("release_date", pre=True)
def _release_date_optional(cls, v):
def _release_date_optional(cls, v: str) -> str | None:
if not v:
return None
return v
@property
def update_available(self):
def update_available(self) -> bool:
"""Return True if update available."""
if self.status != 0:
return True
@@ -69,11 +69,11 @@ class Firmware(SmartModule):
REQUIRED_COMPONENT = "firmware"
MINIMUM_UPDATE_INTERVAL_SECS = 60 * 60 * 24
def __init__(self, device: SmartDevice, module: str):
def __init__(self, device: SmartDevice, module: str) -> None:
super().__init__(device, module)
self._firmware_update_info: UpdateInfo | None = None
def _initialize_features(self):
def _initialize_features(self) -> None:
"""Initialize features."""
device = self._device
if self.supported_version > 1:
@@ -183,7 +183,7 @@ class Firmware(SmartModule):
@allow_update_after
async def update(
self, progress_cb: Callable[[DownloadState], Coroutine] | None = None
):
) -> dict:
"""Update the device firmware."""
if not self._firmware_update_info:
raise KasaException(
@@ -236,13 +236,15 @@ class Firmware(SmartModule):
else:
_LOGGER.warning("Unhandled state code: %s", state)
return state.dict()
@property
def auto_update_enabled(self) -> bool:
"""Return True if autoupdate is enabled."""
return "enable" in self.data and self.data["enable"]
@allow_update_after
async def set_auto_update_enabled(self, enabled: bool):
async def set_auto_update_enabled(self, enabled: bool) -> dict:
"""Change autoupdate setting."""
data = {**self.data, "enable": enabled}
await self.call("set_auto_update_info", data)
return await self.call("set_auto_update_info", data)