From e3e92397984579cc1eb595e87d66b406fb63b8b0 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 6 May 2021 07:04:09 +0200 Subject: [PATCH] Strictly type Twente Milieu integration (#50062) --- .../components/twentemilieu/sensor.py | 19 ++++++++----------- mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/twentemilieu/sensor.py b/homeassistant/components/twentemilieu/sensor.py index c0174263d23..cc17bf6f1a2 100644 --- a/homeassistant/components/twentemilieu/sensor.py +++ b/homeassistant/components/twentemilieu/sensor.py @@ -12,7 +12,7 @@ from twentemilieu import ( from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ID +from homeassistant.const import ATTR_IDENTIFIERS, ATTR_MANUFACTURER, ATTR_NAME, CONF_ID from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -89,7 +89,6 @@ class TwenteMilieuSensor(SensorEntity): self._name = name self._twentemilieu = twentemilieu self._waste_type = waste_type - self._unsub_dispatcher = None self._state = None @@ -120,14 +119,12 @@ class TwenteMilieuSensor(SensorEntity): async def async_added_to_hass(self) -> None: """Connect to dispatcher listening for entity data notifications.""" - self._unsub_dispatcher = async_dispatcher_connect( - self.hass, DATA_UPDATE, self._schedule_immediate_update + self.async_on_remove( + async_dispatcher_connect( + self.hass, DATA_UPDATE, self._schedule_immediate_update + ) ) - async def async_will_remove_from_hass(self) -> None: - """Disconnect from update signal.""" - self._unsub_dispatcher() - @callback def _schedule_immediate_update(self, unique_id: str) -> None: """Schedule an immediate update of the entity.""" @@ -149,7 +146,7 @@ class TwenteMilieuSensor(SensorEntity): def device_info(self) -> DeviceInfo: """Return device information about Twente Milieu.""" return { - "identifiers": {(DOMAIN, self._unique_id)}, - "name": "Twente Milieu", - "manufacturer": "Twente Milieu", + ATTR_IDENTIFIERS: {(DOMAIN, self._unique_id)}, + ATTR_NAME: "Twente Milieu", + ATTR_MANUFACTURER: "Twente Milieu", } diff --git a/mypy.ini b/mypy.ini index 948b2de0e11..e457c331199 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1269,9 +1269,6 @@ ignore_errors = true [mypy-homeassistant.components.tuya.*] ignore_errors = true -[mypy-homeassistant.components.twentemilieu.*] -ignore_errors = true - [mypy-homeassistant.components.unifi.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index dc4485864f9..a1761f2847f 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -226,7 +226,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.trace.*", "homeassistant.components.tradfri.*", "homeassistant.components.tuya.*", - "homeassistant.components.twentemilieu.*", "homeassistant.components.unifi.*", "homeassistant.components.upcloud.*", "homeassistant.components.updater.*",