Add yale_smart_alarm to strict typing (#68422)

* Add yale_smart_alarm to strict typing

* Type as Any
This commit is contained in:
G Johansson 2022-03-20 18:50:37 +01:00 committed by GitHub
parent 1013f77013
commit 89cfb4e86f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 10 deletions

View File

@ -224,6 +224,7 @@ homeassistant.components.wemo.*
homeassistant.components.whois.*
homeassistant.components.wiz.*
homeassistant.components.worldclock.*
homeassistant.components.yale_smart_alarm.*
homeassistant.components.zodiac.*
homeassistant.components.zeroconf.*
homeassistant.components.zone.*

View File

@ -92,15 +92,15 @@ class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
self._attr_name = coordinator.entry.data[CONF_NAME]
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."""
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."""
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."""
return await self.async_set_alarm(YALE_STATE_ARM_FULL, code)

View File

@ -69,7 +69,7 @@ class YaleDoorSensor(YaleEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""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):
@ -93,7 +93,7 @@ class YaleProblemSensor(YaleAlarmEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Return true if the binary sensor is on."""
return (
return bool(
self.coordinator.data["status"][self.entity_description.key]
!= "main.normal"
)

View File

@ -1,7 +1,7 @@
"""Lock for Yale Alarm."""
from __future__ import annotations
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any
from homeassistant.components.lock import LockEntity
from homeassistant.config_entries import ConfigEntry
@ -47,12 +47,14 @@ class YaleDoorlock(YaleEntity, LockEntity):
super().__init__(coordinator, data)
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."""
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)
async def async_lock(self, **kwargs) -> None:
async def async_lock(self, **kwargs: Any) -> None:
"""Send lock command."""
return await self.async_set_lock("locked", None)
@ -88,4 +90,4 @@ class YaleDoorlock(YaleEntity, LockEntity):
@property
def is_locked(self) -> bool | None:
"""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")

View File

@ -2266,6 +2266,17 @@ no_implicit_optional = true
warn_return_any = 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.*]
check_untyped_defs = true
disallow_incomplete_defs = true