From d08f7f952653eeb494fc9e480aad323389c9a106 Mon Sep 17 00:00:00 2001 From: Yuval Aboulafia Date: Tue, 4 Oct 2022 01:02:20 +0300 Subject: [PATCH] Add clickatell to strict typing (#79497) * type clickatell * follow review --- .strict-typing | 1 + homeassistant/components/clickatell/notify.py | 19 ++++++++++++++----- mypy.ini | 10 ++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.strict-typing b/.strict-typing index cc90af1b98b..303f732018c 100644 --- a/.strict-typing +++ b/.strict-typing @@ -77,6 +77,7 @@ homeassistant.components.calendar.* homeassistant.components.camera.* homeassistant.components.canary.* homeassistant.components.cover.* +homeassistant.components.clickatell.* homeassistant.components.cpuspeed.* homeassistant.components.crownstone.* homeassistant.components.deconz.* diff --git a/homeassistant/components/clickatell/notify.py b/homeassistant/components/clickatell/notify.py index fdefb25aef4..8422f7295b3 100644 --- a/homeassistant/components/clickatell/notify.py +++ b/homeassistant/components/clickatell/notify.py @@ -1,13 +1,18 @@ """Clickatell platform for notify component.""" +from __future__ import annotations + from http import HTTPStatus import logging +from typing import Any import requests import voluptuous as vol from homeassistant.components.notify import PLATFORM_SCHEMA, BaseNotificationService from homeassistant.const import CONF_API_KEY, CONF_RECIPIENT +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) @@ -20,7 +25,11 @@ 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, +) -> ClickatellNotificationService: """Get the Clickatell notification service.""" return ClickatellNotificationService(config) @@ -28,12 +37,12 @@ def get_service(hass, config, discovery_info=None): class ClickatellNotificationService(BaseNotificationService): """Implementation of a notification service for the Clickatell service.""" - def __init__(self, config): + def __init__(self, config: ConfigType) -> None: """Initialize the service.""" - self.api_key = config[CONF_API_KEY] - self.recipient = config[CONF_RECIPIENT] + self.api_key: str = config[CONF_API_KEY] + self.recipient: str = config[CONF_RECIPIENT] - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" data = {"apiKey": self.api_key, "to": self.recipient, "content": message} diff --git a/mypy.ini b/mypy.ini index 04986db451c..4aa0b5cbeb3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -522,6 +522,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.clickatell.*] +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