From 7524acc38c819bef7a83c0ce892fa621224b2cf3 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Tue, 17 Aug 2021 00:19:12 +0200 Subject: [PATCH] Activate mypy for sesame (#54546) --- homeassistant/components/sesame/lock.py | 29 +++++++------------------ mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/homeassistant/components/sesame/lock.py b/homeassistant/components/sesame/lock.py index acd71b7c9e7..261b2680499 100644 --- a/homeassistant/components/sesame/lock.py +++ b/homeassistant/components/sesame/lock.py @@ -1,17 +1,11 @@ """Support for Sesame, by CANDY HOUSE.""" -from typing import Callable +from __future__ import annotations import pysesame2 import voluptuous as vol from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity -from homeassistant.const import ( - ATTR_BATTERY_LEVEL, - ATTR_DEVICE_ID, - CONF_API_KEY, - STATE_LOCKED, - STATE_UNLOCKED, -) +from homeassistant.const import ATTR_BATTERY_LEVEL, ATTR_DEVICE_ID, CONF_API_KEY import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType @@ -20,9 +14,7 @@ ATTR_SERIAL_NO = "serial" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_API_KEY): cv.string}) -def setup_platform( - hass, config: ConfigType, add_entities: Callable[[list], None], discovery_info=None -): +def setup_platform(hass, config: ConfigType, add_entities, discovery_info=None): """Set up the Sesame platform.""" api_key = config.get(CONF_API_KEY) @@ -35,20 +27,20 @@ def setup_platform( class SesameDevice(LockEntity): """Representation of a Sesame device.""" - def __init__(self, sesame: object) -> None: + def __init__(self, sesame: pysesame2.Sesame) -> None: """Initialize the Sesame device.""" - self._sesame = sesame + self._sesame: pysesame2.Sesame = sesame # Cached properties from pysesame object. - self._device_id = None + self._device_id: str | None = None self._serial = None - self._nickname = None + self._nickname: str | None = None self._is_locked = False self._responsive = False self._battery = -1 @property - def name(self) -> str: + def name(self) -> str | None: """Return the name of the device.""" return self._nickname @@ -62,11 +54,6 @@ class SesameDevice(LockEntity): """Return True if the device is currently locked, else False.""" return self._is_locked - @property - def state(self) -> str: - """Get the state of the device.""" - return STATE_LOCKED if self._is_locked else STATE_UNLOCKED - def lock(self, **kwargs) -> None: """Lock the device.""" self._sesame.lock() diff --git a/mypy.ini b/mypy.ini index a12719f90df..837dc73343a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1604,9 +1604,6 @@ ignore_errors = true [mypy-homeassistant.components.sense.*] ignore_errors = true -[mypy-homeassistant.components.sesame.*] -ignore_errors = true - [mypy-homeassistant.components.sharkiq.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index dc00be3efe4..513be3e59c2 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -127,7 +127,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.screenlogic.*", "homeassistant.components.search.*", "homeassistant.components.sense.*", - "homeassistant.components.sesame.*", "homeassistant.components.sharkiq.*", "homeassistant.components.sma.*", "homeassistant.components.smartthings.*",