diff --git a/.strict-typing b/.strict-typing index f267925ad19..d60b99822b9 100644 --- a/.strict-typing +++ b/.strict-typing @@ -78,6 +78,7 @@ homeassistant.components.sun.* homeassistant.components.switch.* homeassistant.components.synology_dsm.* homeassistant.components.systemmonitor.* +homeassistant.components.tag.* homeassistant.components.tcp.* homeassistant.components.tts.* homeassistant.components.upcloud.* diff --git a/homeassistant/components/tag/__init__.py b/homeassistant/components/tag/__init__.py index 4a410c6b30b..c05b4416343 100644 --- a/homeassistant/components/tag/__init__.py +++ b/homeassistant/components/tag/__init__.py @@ -7,11 +7,12 @@ import uuid import voluptuous as vol from homeassistant.const import CONF_NAME -from homeassistant.core import HomeAssistant, callback +from homeassistant.core import Context, HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import collection import homeassistant.helpers.config_validation as cv from homeassistant.helpers.storage import Store +from homeassistant.helpers.typing import ConfigType from homeassistant.loader import bind_hass import homeassistant.util.dt as dt_util @@ -75,7 +76,7 @@ class TagStorageCollection(collection.StorageCollection): return data @callback - def _get_suggested_id(self, info: dict) -> str: + def _get_suggested_id(self, info: dict[str, str]) -> str: """Suggest an ID based on the config.""" return info[TAG_ID] @@ -88,7 +89,7 @@ class TagStorageCollection(collection.StorageCollection): return data -async def async_setup(hass: HomeAssistant, config: dict): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Tag component.""" hass.data[DOMAIN] = {} id_manager = TagIDManager() @@ -106,7 +107,9 @@ async def async_setup(hass: HomeAssistant, config: dict): @bind_hass -async def async_scan_tag(hass, tag_id, device_id, context=None): +async def async_scan_tag( + hass: HomeAssistant, tag_id: str, device_id: str, context: Context | None = None +) -> None: """Handle when a tag is scanned.""" if DOMAIN not in hass.config.components: raise HomeAssistantError("tag component has not been set up.") diff --git a/homeassistant/components/tag/trigger.py b/homeassistant/components/tag/trigger.py index 1984505f3a6..ba90f0a9396 100644 --- a/homeassistant/components/tag/trigger.py +++ b/homeassistant/components/tag/trigger.py @@ -1,9 +1,11 @@ """Support for tag triggers.""" import voluptuous as vol +from homeassistant.components.automation import AutomationActionType from homeassistant.const import CONF_PLATFORM -from homeassistant.core import HassJob +from homeassistant.core import CALLBACK_TYPE, Event, HassJob, HomeAssistant from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType from .const import DEVICE_ID, DOMAIN, EVENT_TAG_SCANNED, TAG_ID @@ -16,7 +18,12 @@ TRIGGER_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( ) -async def async_attach_trigger(hass, config, action, automation_info): +async def async_attach_trigger( + hass: HomeAssistant, + config: ConfigType, + action: AutomationActionType, + automation_info: dict, +) -> CALLBACK_TYPE: """Listen for tag_scanned events based on configuration.""" trigger_data = automation_info.get("trigger_data", {}) if automation_info else {} tag_ids = set(config[TAG_ID]) @@ -24,7 +31,7 @@ async def async_attach_trigger(hass, config, action, automation_info): job = HassJob(action) - async def handle_event(event): + async def handle_event(event: Event) -> None: """Listen for tag scan events and calls the action when data matches.""" if event.data.get(TAG_ID) not in tag_ids or ( device_ids is not None and event.data.get(DEVICE_ID) not in device_ids diff --git a/mypy.ini b/mypy.ini index f6079c74e13..521e5cc4b7d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -869,6 +869,17 @@ no_implicit_optional = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.tag.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +no_implicit_optional = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.tcp.*] check_untyped_defs = true disallow_incomplete_defs = true