mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 13:45:12 +02:00
Add yale_smart_alarm to strict typing (#68422)
* Add yale_smart_alarm to strict typing * Type as Any
This commit is contained in:
@@ -224,6 +224,7 @@ homeassistant.components.wemo.*
|
|||||||
homeassistant.components.whois.*
|
homeassistant.components.whois.*
|
||||||
homeassistant.components.wiz.*
|
homeassistant.components.wiz.*
|
||||||
homeassistant.components.worldclock.*
|
homeassistant.components.worldclock.*
|
||||||
|
homeassistant.components.yale_smart_alarm.*
|
||||||
homeassistant.components.zodiac.*
|
homeassistant.components.zodiac.*
|
||||||
homeassistant.components.zeroconf.*
|
homeassistant.components.zeroconf.*
|
||||||
homeassistant.components.zone.*
|
homeassistant.components.zone.*
|
||||||
|
@@ -92,15 +92,15 @@ class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
|
|||||||
self._attr_name = coordinator.entry.data[CONF_NAME]
|
self._attr_name = coordinator.entry.data[CONF_NAME]
|
||||||
self._attr_unique_id = coordinator.entry.entry_id
|
self._attr_unique_id = coordinator.entry.entry_id
|
||||||
|
|
||||||
async def async_alarm_disarm(self, code=None) -> None:
|
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
return await self.async_set_alarm(YALE_STATE_DISARM, code)
|
return await self.async_set_alarm(YALE_STATE_DISARM, code)
|
||||||
|
|
||||||
async def async_alarm_arm_home(self, code=None) -> None:
|
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||||
"""Send arm home command."""
|
"""Send arm home command."""
|
||||||
return await self.async_set_alarm(YALE_STATE_ARM_PARTIAL, code)
|
return await self.async_set_alarm(YALE_STATE_ARM_PARTIAL, code)
|
||||||
|
|
||||||
async def async_alarm_arm_away(self, code=None) -> None:
|
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||||
"""Send arm away command."""
|
"""Send arm away command."""
|
||||||
return await self.async_set_alarm(YALE_STATE_ARM_FULL, code)
|
return await self.async_set_alarm(YALE_STATE_ARM_FULL, code)
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ class YaleDoorSensor(YaleEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if the binary sensor is on."""
|
"""Return true if the binary sensor is on."""
|
||||||
return self.coordinator.data["sensor_map"][self._attr_unique_id] == "open"
|
return bool(self.coordinator.data["sensor_map"][self._attr_unique_id] == "open")
|
||||||
|
|
||||||
|
|
||||||
class YaleProblemSensor(YaleAlarmEntity, BinarySensorEntity):
|
class YaleProblemSensor(YaleAlarmEntity, BinarySensorEntity):
|
||||||
@@ -93,7 +93,7 @@ class YaleProblemSensor(YaleAlarmEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if the binary sensor is on."""
|
"""Return true if the binary sensor is on."""
|
||||||
return (
|
return bool(
|
||||||
self.coordinator.data["status"][self.entity_description.key]
|
self.coordinator.data["status"][self.entity_description.key]
|
||||||
!= "main.normal"
|
!= "main.normal"
|
||||||
)
|
)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
"""Lock for Yale Alarm."""
|
"""Lock for Yale Alarm."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from homeassistant.components.lock import LockEntity
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@@ -47,12 +47,14 @@ class YaleDoorlock(YaleEntity, LockEntity):
|
|||||||
super().__init__(coordinator, data)
|
super().__init__(coordinator, data)
|
||||||
self._attr_code_format = f"^\\d{code_format}$"
|
self._attr_code_format = f"^\\d{code_format}$"
|
||||||
|
|
||||||
async def async_unlock(self, **kwargs) -> None:
|
async def async_unlock(self, **kwargs: Any) -> None:
|
||||||
"""Send unlock command."""
|
"""Send unlock command."""
|
||||||
code = kwargs.get(ATTR_CODE, self.coordinator.entry.options.get(CONF_CODE))
|
code: str | None = kwargs.get(
|
||||||
|
ATTR_CODE, self.coordinator.entry.options.get(CONF_CODE)
|
||||||
|
)
|
||||||
return await self.async_set_lock("unlocked", code)
|
return await self.async_set_lock("unlocked", code)
|
||||||
|
|
||||||
async def async_lock(self, **kwargs) -> None:
|
async def async_lock(self, **kwargs: Any) -> None:
|
||||||
"""Send lock command."""
|
"""Send lock command."""
|
||||||
return await self.async_set_lock("locked", None)
|
return await self.async_set_lock("locked", None)
|
||||||
|
|
||||||
@@ -88,4 +90,4 @@ class YaleDoorlock(YaleEntity, LockEntity):
|
|||||||
@property
|
@property
|
||||||
def is_locked(self) -> bool | None:
|
def is_locked(self) -> bool | None:
|
||||||
"""Return true if the lock is locked."""
|
"""Return true if the lock is locked."""
|
||||||
return self.coordinator.data["lock_map"][self._attr_unique_id] == "locked"
|
return bool(self.coordinator.data["lock_map"][self._attr_unique_id] == "locked")
|
||||||
|
11
mypy.ini
11
mypy.ini
@@ -2266,6 +2266,17 @@ no_implicit_optional = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.yale_smart_alarm.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
no_implicit_optional = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.zodiac.*]
|
[mypy-homeassistant.components.zodiac.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Reference in New Issue
Block a user