1
0
mirror of https://github.com/home-assistant/core synced 2024-06-29 06:15:03 +00:00

Add Roborock to strict typing (#120379)

This commit is contained in:
Luke Lashley 2024-06-26 08:13:49 -04:00 committed by GitHub
parent 0d2aeb846f
commit 69e0227682
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 8 deletions

View File

@ -370,6 +370,7 @@ homeassistant.components.rhasspy.*
homeassistant.components.ridwell.*
homeassistant.components.ring.*
homeassistant.components.rituals_perfume_genie.*
homeassistant.components.roborock.*
homeassistant.components.roku.*
homeassistant.components.romy.*
homeassistant.components.rpi_power.*

View File

@ -1,6 +1,7 @@
"""Support for Roborock image."""
import asyncio
from datetime import datetime
import io
from itertools import chain
@ -48,6 +49,7 @@ class RoborockMap(RoborockCoordinatedEntity, ImageEntity):
"""A class to let you visualize the map."""
_attr_has_entity_name = True
image_last_updated: datetime
def __init__(
self,
@ -76,7 +78,7 @@ class RoborockMap(RoborockCoordinatedEntity, ImageEntity):
self._attr_entity_category = EntityCategory.DIAGNOSTIC
@property
def available(self):
def available(self) -> bool:
"""Determines if the entity is available."""
return self.cached_map != b""
@ -98,7 +100,7 @@ class RoborockMap(RoborockCoordinatedEntity, ImageEntity):
and bool(self.coordinator.roborock_device_info.props.status.in_cleaning)
)
def _handle_coordinator_update(self):
def _handle_coordinator_update(self) -> None:
# Bump last updated every third time the coordinator runs, so that async_image
# will be called and we will evaluate on the new coordinator data if we should
# update the cache.

View File

@ -107,7 +107,8 @@ class RoborockNumberEntity(RoborockEntity, NumberEntity):
@property
def native_value(self) -> float | None:
"""Get native value."""
return self.get_cache(self.entity_description.cache_key).value
val: float = self.get_cache(self.entity_description.cache_key).value
return val
async def async_set_native_value(self, value: float) -> None:
"""Set number value."""

View File

@ -167,9 +167,9 @@ class RoborockSwitch(RoborockEntity, SwitchEntity):
@property
def is_on(self) -> bool | None:
"""Return True if entity is on."""
return (
self.get_cache(self.entity_description.cache_key).value.get(
self.entity_description.attribute
)
== 1
status = self.get_cache(self.entity_description.cache_key).value.get(
self.entity_description.attribute
)
if status is None:
return status
return bool(status)

View File

@ -3463,6 +3463,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.roborock.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.roku.*]
check_untyped_defs = true
disallow_incomplete_defs = true