Activate mypy for sesame (#54546)

This commit is contained in:
jan iversen 2021-08-17 00:19:12 +02:00 committed by GitHub
parent 38a210292f
commit 7524acc38c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 25 deletions

View File

@ -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()

View File

@ -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

View File

@ -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.*",