diff --git a/.strict-typing b/.strict-typing index 264b28408f9..f81b6249fed 100644 --- a/.strict-typing +++ b/.strict-typing @@ -114,6 +114,7 @@ homeassistant.components.homekit.aidmanager homeassistant.components.homekit.config_flow homeassistant.components.homekit.diagnostics homeassistant.components.homekit.logbook +homeassistant.components.homekit.type_locks homeassistant.components.homekit.type_triggers homeassistant.components.homekit.util homeassistant.components.homekit_controller diff --git a/homeassistant/components/homekit/type_locks.py b/homeassistant/components/homekit/type_locks.py index af7501e1869..18dfe48b2bd 100644 --- a/homeassistant/components/homekit/type_locks.py +++ b/homeassistant/components/homekit/type_locks.py @@ -1,5 +1,6 @@ """Class to hold all lock accessories.""" import logging +from typing import Any from pyhap.const import CATEGORY_DOOR_LOCK @@ -12,7 +13,7 @@ from homeassistant.components.lock import ( STATE_UNLOCKING, ) from homeassistant.const import ATTR_CODE, ATTR_ENTITY_ID, STATE_UNKNOWN -from homeassistant.core import callback +from homeassistant.core import State, callback from .accessories import TYPES, HomeAccessory from .const import CHAR_LOCK_CURRENT_STATE, CHAR_LOCK_TARGET_STATE, SERV_LOCK @@ -59,11 +60,12 @@ class Lock(HomeAccessory): The lock entity must support: unlock and lock. """ - def __init__(self, *args): + def __init__(self, *args: Any) -> None: """Initialize a Lock accessory object.""" super().__init__(*args, category=CATEGORY_DOOR_LOCK) self._code = self.config.get(ATTR_CODE) state = self.hass.states.get(self.entity_id) + assert state is not None serv_lock_mechanism = self.add_preload_service(SERV_LOCK) self.char_current_state = serv_lock_mechanism.configure_char( @@ -76,7 +78,7 @@ class Lock(HomeAccessory): ) self.async_update_state(state) - def set_state(self, value): + def set_state(self, value: int) -> None: """Set lock state to value if call came from HomeKit.""" _LOGGER.debug("%s: Set state to %d", self.entity_id, value) @@ -89,7 +91,7 @@ class Lock(HomeAccessory): self.async_call_service(DOMAIN, service, params) @callback - def async_update_state(self, new_state): + def async_update_state(self, new_state: State) -> None: """Update lock after state changed.""" hass_state = new_state.state current_lock_state = HASS_TO_HOMEKIT_CURRENT.get( diff --git a/mypy.ini b/mypy.ini index 522cda67e79..11a2d83ec40 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1017,6 +1017,17 @@ no_implicit_optional = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.homekit.type_locks] +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.homekit.type_triggers] check_untyped_defs = true disallow_incomplete_defs = true