Add clickatell to strict typing (#79497)
* type clickatell * follow review
This commit is contained in:
parent
42de69b6d5
commit
d08f7f9526
3 changed files with 25 additions and 5 deletions
|
@ -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.*
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
10
mypy.ini
10
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
|
||||
|
|
Loading…
Add table
Reference in a new issue