diff --git a/.strict-typing b/.strict-typing index 2390ab8373d..635356f4950 100644 --- a/.strict-typing +++ b/.strict-typing @@ -78,6 +78,7 @@ homeassistant.components.camera.* homeassistant.components.canary.* homeassistant.components.cover.* homeassistant.components.clickatell.* +homeassistant.components.clicksend.* homeassistant.components.cpuspeed.* homeassistant.components.crownstone.* homeassistant.components.deconz.* diff --git a/homeassistant/components/clicksend/notify.py b/homeassistant/components/clicksend/notify.py index ec6bed3c55d..36ac21d8dd3 100644 --- a/homeassistant/components/clicksend/notify.py +++ b/homeassistant/components/clicksend/notify.py @@ -1,7 +1,10 @@ """Clicksend platform for notify component.""" +from __future__ import annotations + from http import HTTPStatus import json import logging +from typing import Any import requests import voluptuous as vol @@ -14,7 +17,9 @@ from homeassistant.const import ( CONF_USERNAME, CONTENT_TYPE_JSON, ) +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) @@ -41,7 +46,11 @@ PLATFORM_SCHEMA = vol.Schema( ) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> ClicksendNotificationService | None: """Get the ClickSend notification service.""" if not _authenticate(config): _LOGGER.error("You are not authorized to access ClickSend") @@ -52,16 +61,16 @@ def get_service(hass, config, discovery_info=None): class ClicksendNotificationService(BaseNotificationService): """Implementation of a notification service for the ClickSend service.""" - def __init__(self, config): + def __init__(self, config: ConfigType) -> None: """Initialize the service.""" - self.username = config[CONF_USERNAME] - self.api_key = config[CONF_API_KEY] - self.recipients = config[CONF_RECIPIENT] - self.sender = config[CONF_SENDER] + self.username: str = config[CONF_USERNAME] + self.api_key: str = config[CONF_API_KEY] + self.recipients: list[str] = config[CONF_RECIPIENT] + self.sender: str = config[CONF_SENDER] - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" - data = {"messages": []} + data: dict[str, Any] = {"messages": []} for recipient in self.recipients: data["messages"].append( { @@ -91,7 +100,7 @@ class ClicksendNotificationService(BaseNotificationService): ) -def _authenticate(config): +def _authenticate(config: ConfigType) -> bool: """Authenticate with ClickSend.""" api_url = f"{BASE_API_URL}/account" resp = requests.get( diff --git a/mypy.ini b/mypy.ini index 4aa0b5cbeb3..267e856aa09 100644 --- a/mypy.ini +++ b/mypy.ini @@ -532,6 +532,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.clicksend.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.cpuspeed.*] check_untyped_defs = true disallow_incomplete_defs = true