diff --git a/.strict-typing b/.strict-typing index e4e9d46847a..b653a8f0c65 100644 --- a/.strict-typing +++ b/.strict-typing @@ -100,6 +100,7 @@ homeassistant.components.jellyfin.* homeassistant.components.jewish_calendar.* homeassistant.components.knx.* homeassistant.components.kraken.* +homeassistant.components.lametric.* homeassistant.components.lcn.* homeassistant.components.light.* homeassistant.components.local_ip.* diff --git a/homeassistant/components/lametric/__init__.py b/homeassistant/components/lametric/__init__.py index f0384e457e4..1c84c4f5510 100644 --- a/homeassistant/components/lametric/__init__.py +++ b/homeassistant/components/lametric/__init__.py @@ -50,7 +50,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: class HassLaMetricManager: """A class that encapsulated requests to the LaMetric manager.""" - def __init__(self, client_id, client_secret): + def __init__(self, client_id: str, client_secret: str) -> None: """Initialize HassLaMetricManager and connect to LaMetric.""" _LOGGER.debug("Connecting to LaMetric") diff --git a/homeassistant/components/lametric/notify.py b/homeassistant/components/lametric/notify.py index d04225f2ce4..034deb911d1 100644 --- a/homeassistant/components/lametric/notify.py +++ b/homeassistant/components/lametric/notify.py @@ -1,5 +1,8 @@ """Support for LaMetric notifications.""" +from __future__ import annotations + import logging +from typing import Any from lmnotify import Model, SimpleFrame, Sound from oauthlib.oauth2 import TokenExpiredError @@ -13,9 +16,11 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import CONF_ICON +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import DOMAIN as LAMETRIC_DOMAIN +from . import DOMAIN, HassLaMetricManager _LOGGER = logging.getLogger(__name__) @@ -38,11 +43,14 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( ) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> LaMetricNotificationService: """Get the LaMetric notification service.""" - hlmn = hass.data.get(LAMETRIC_DOMAIN) return LaMetricNotificationService( - hlmn, + hass.data[DOMAIN], config[CONF_ICON], config[CONF_LIFETIME] * 1000, config[CONF_CYCLES], @@ -55,8 +63,14 @@ class LaMetricNotificationService(BaseNotificationService): """Implement the notification service for LaMetric.""" def __init__( - self, hasslametricmanager, icon, lifetime, cycles, priority, icon_type - ): + self, + hasslametricmanager: HassLaMetricManager, + icon: str, + lifetime: int, + cycles: int, + priority: str, + icon_type: str, + ) -> None: """Initialize the service.""" self.hasslametricmanager = hasslametricmanager self._icon = icon @@ -64,9 +78,9 @@ class LaMetricNotificationService(BaseNotificationService): self._cycles = cycles self._priority = priority self._icon_type = icon_type - self._devices = [] + self._devices: list[dict[str, Any]] = [] - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to some LaMetric device.""" targets = kwargs.get(ATTR_TARGET) diff --git a/mypy.ini b/mypy.ini index 31d929d39d8..5ea6d9b3005 100644 --- a/mypy.ini +++ b/mypy.ini @@ -912,6 +912,17 @@ no_implicit_optional = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.lametric.*] +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.lcn.*] check_untyped_defs = true disallow_incomplete_defs = true