From 94a8fe0052635299834b8006904609b2e983490e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 15 Jun 2022 10:45:47 +0200 Subject: [PATCH] Remove xiaomi_aqara from mypy ignore list (#73526) --- homeassistant/components/xiaomi_aqara/__init__.py | 9 +++++---- .../components/xiaomi_aqara/binary_sensor.py | 2 +- homeassistant/components/xiaomi_aqara/lock.py | 7 +++++-- homeassistant/components/xiaomi_aqara/sensor.py | 2 +- mypy.ini | 12 ------------ script/hassfest/mypy_config.py | 4 ---- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/xiaomi_aqara/__init__.py b/homeassistant/components/xiaomi_aqara/__init__.py index 1857b6e83b2..0c9696a42ef 100644 --- a/homeassistant/components/xiaomi_aqara/__init__.py +++ b/homeassistant/components/xiaomi_aqara/__init__.py @@ -82,7 +82,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: def play_ringtone_service(call: ServiceCall) -> None: """Service to play ringtone through Gateway.""" ring_id = call.data.get(ATTR_RINGTONE_ID) - gateway = call.data.get(ATTR_GW_MAC) + gateway: XiaomiGateway = call.data[ATTR_GW_MAC] kwargs = {"mid": ring_id} @@ -93,12 +93,12 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: def stop_ringtone_service(call: ServiceCall) -> None: """Service to stop playing ringtone on Gateway.""" - gateway = call.data.get(ATTR_GW_MAC) + gateway: XiaomiGateway = call.data[ATTR_GW_MAC] gateway.write_to_hub(gateway.sid, mid=10000) def add_device_service(call: ServiceCall) -> None: """Service to add a new sub-device within the next 30 seconds.""" - gateway = call.data.get(ATTR_GW_MAC) + gateway: XiaomiGateway = call.data[ATTR_GW_MAC] gateway.write_to_hub(gateway.sid, join_permission="yes") persistent_notification.async_create( hass, @@ -110,7 +110,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: def remove_device_service(call: ServiceCall) -> None: """Service to remove a sub-device from the gateway.""" device_id = call.data.get(ATTR_DEVICE_ID) - gateway = call.data.get(ATTR_GW_MAC) + gateway: XiaomiGateway = call.data[ATTR_GW_MAC] gateway.write_to_hub(gateway.sid, remove_device=device_id) gateway_only_schema = _add_gateway_to_schema(hass, vol.Schema({})) @@ -181,6 +181,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.data[CONF_HOST], ) + assert entry.unique_id device_registry = dr.async_get(hass) device_registry.async_get_or_create( config_entry_id=entry.entry_id, diff --git a/homeassistant/components/xiaomi_aqara/binary_sensor.py b/homeassistant/components/xiaomi_aqara/binary_sensor.py index ef773805849..04e3945e7a2 100644 --- a/homeassistant/components/xiaomi_aqara/binary_sensor.py +++ b/homeassistant/components/xiaomi_aqara/binary_sensor.py @@ -34,7 +34,7 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Perform the setup for Xiaomi devices.""" - entities = [] + entities: list[XiaomiBinarySensor] = [] gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id] for entity in gateway.devices["binary_sensor"]: model = entity["model"] diff --git a/homeassistant/components/xiaomi_aqara/lock.py b/homeassistant/components/xiaomi_aqara/lock.py index e21967a9f06..1885c1aef85 100644 --- a/homeassistant/components/xiaomi_aqara/lock.py +++ b/homeassistant/components/xiaomi_aqara/lock.py @@ -1,4 +1,6 @@ """Support for Xiaomi Aqara locks.""" +from __future__ import annotations + from homeassistant.components.lock import LockEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED @@ -44,13 +46,14 @@ class XiaomiAqaraLock(LockEntity, XiaomiDevice): super().__init__(device, name, xiaomi_hub, config_entry) @property - def is_locked(self) -> bool: + def is_locked(self) -> bool | None: """Return true if lock is locked.""" if self._state is not None: return self._state == STATE_LOCKED + return None @property - def changed_by(self) -> int: + def changed_by(self) -> str: """Last change triggered by.""" return self._changed_by diff --git a/homeassistant/components/xiaomi_aqara/sensor.py b/homeassistant/components/xiaomi_aqara/sensor.py index 3e0d49d628f..5deed77d775 100644 --- a/homeassistant/components/xiaomi_aqara/sensor.py +++ b/homeassistant/components/xiaomi_aqara/sensor.py @@ -88,7 +88,7 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Perform the setup for Xiaomi devices.""" - entities = [] + entities: list[XiaomiSensor | XiaomiBatterySensor] = [] gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id] for device in gateway.devices["sensor"]: if device["model"] == "sensor_ht": diff --git a/mypy.ini b/mypy.ini index 9e27addae89..8a9c5b0478a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2976,18 +2976,6 @@ ignore_errors = true [mypy-homeassistant.components.xbox.sensor] ignore_errors = true -[mypy-homeassistant.components.xiaomi_aqara] -ignore_errors = true - -[mypy-homeassistant.components.xiaomi_aqara.binary_sensor] -ignore_errors = true - -[mypy-homeassistant.components.xiaomi_aqara.lock] -ignore_errors = true - -[mypy-homeassistant.components.xiaomi_aqara.sensor] -ignore_errors = true - [mypy-homeassistant.components.xiaomi_miio] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 0b705fab983..b7fb778cfee 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -141,10 +141,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.xbox.browse_media", "homeassistant.components.xbox.media_source", "homeassistant.components.xbox.sensor", - "homeassistant.components.xiaomi_aqara", - "homeassistant.components.xiaomi_aqara.binary_sensor", - "homeassistant.components.xiaomi_aqara.lock", - "homeassistant.components.xiaomi_aqara.sensor", "homeassistant.components.xiaomi_miio", "homeassistant.components.xiaomi_miio.air_quality", "homeassistant.components.xiaomi_miio.binary_sensor",