mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Add Roborock to strict typing (#120379)
This commit is contained in:
parent
0d2aeb846f
commit
69e0227682
@ -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.*
|
||||
|
@ -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.
|
||||
|
@ -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."""
|
||||
|
@ -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)
|
||||
|
10
mypy.ini
10
mypy.ini
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user