From 98fdb00bc731d909c94afc8ef49f304bd11458ae Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 2 Jul 2021 16:45:38 +0200 Subject: [PATCH] Enable basic type checking for Tasmota (#52435) --- homeassistant/components/tasmota/device_trigger.py | 6 +++--- homeassistant/components/tasmota/discovery.py | 4 ++-- mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/tasmota/device_trigger.py b/homeassistant/components/tasmota/device_trigger.py index 6a6f0324e1d..8ec368e326f 100644 --- a/homeassistant/components/tasmota/device_trigger.py +++ b/homeassistant/components/tasmota/device_trigger.py @@ -81,9 +81,9 @@ class Trigger: """Device trigger settings.""" device_id: str = attr.ib() - discovery_hash: dict = attr.ib() + discovery_hash: dict | None = attr.ib() hass: HomeAssistant = attr.ib() - remove_update_signal: Callable[[], None] = attr.ib() + remove_update_signal: Callable[[], None] | None = attr.ib() subtype: str = attr.ib() tasmota_trigger: TasmotaTrigger = attr.ib() type: str = attr.ib() @@ -242,7 +242,7 @@ async def async_remove_triggers(hass: HomeAssistant, device_id: str): async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]: """List device triggers for a Tasmota device.""" - triggers = [] + triggers: list[dict[str, str]] = [] if DEVICE_TRIGGERS not in hass.data: return triggers diff --git a/homeassistant/components/tasmota/discovery.py b/homeassistant/components/tasmota/discovery.py index b69307693da..ad3604c06c2 100644 --- a/homeassistant/components/tasmota/discovery.py +++ b/homeassistant/components/tasmota/discovery.py @@ -42,7 +42,7 @@ def set_discovery_hash(hass, discovery_hash): async def async_start( hass: HomeAssistant, discovery_topic, config_entry, tasmota_mqtt, setup_device -) -> bool: +) -> None: """Start Tasmota device discovery.""" async def _discover_entity(tasmota_entity_config, discovery_hash, platform): @@ -171,7 +171,7 @@ async def async_start( hass.data[TASMOTA_DISCOVERY_INSTANCE] = tasmota_discovery -async def async_stop(hass: HomeAssistant) -> bool: +async def async_stop(hass: HomeAssistant) -> None: """Stop Tasmota device discovery.""" hass.data.pop(ALREADY_DISCOVERED) tasmota_discovery = hass.data.pop(TASMOTA_DISCOVERY_INSTANCE) diff --git a/mypy.ini b/mypy.ini index 4472311279f..5f2eeb11c7d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1534,9 +1534,6 @@ ignore_errors = true [mypy-homeassistant.components.tado.*] ignore_errors = true -[mypy-homeassistant.components.tasmota.*] -ignore_errors = true - [mypy-homeassistant.components.telegram_bot.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 601e6b55845..e59a59de7c9 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -199,7 +199,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.system_health.*", "homeassistant.components.system_log.*", "homeassistant.components.tado.*", - "homeassistant.components.tasmota.*", "homeassistant.components.telegram_bot.*", "homeassistant.components.template.*", "homeassistant.components.tesla.*",