diff --git a/homeassistant/components/azure_service_bus/notify.py b/homeassistant/components/azure_service_bus/notify.py index 83eb8076fef..5943ec8f855 100644 --- a/homeassistant/components/azure_service_bus/notify.py +++ b/homeassistant/components/azure_service_bus/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations import json import logging +from typing import Any from azure.servicebus import ServiceBusMessage from azure.servicebus.aio import ServiceBusClient, ServiceBusSender @@ -92,7 +93,7 @@ class ServiceBusNotificationService(BaseNotificationService): """Initialize the service.""" self._client = client - async def async_send_message(self, message, **kwargs): + async def async_send_message(self, message: str, **kwargs: Any) -> None: """Send a message.""" dto = {ATTR_ASB_MESSAGE: message} diff --git a/homeassistant/components/cisco_webex_teams/notify.py b/homeassistant/components/cisco_webex_teams/notify.py index 2f76ed8f65a..888af58b798 100644 --- a/homeassistant/components/cisco_webex_teams/notify.py +++ b/homeassistant/components/cisco_webex_teams/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol from webexpythonsdk import ApiError, WebexAPI, exceptions @@ -51,7 +52,7 @@ class CiscoWebexNotificationService(BaseNotificationService): self.room = room self.client = client - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" title = "" diff --git a/homeassistant/components/clicksend_tts/notify.py b/homeassistant/components/clicksend_tts/notify.py index 5a08ccd7988..632b76bc7be 100644 --- a/homeassistant/components/clicksend_tts/notify.py +++ b/homeassistant/components/clicksend_tts/notify.py @@ -5,6 +5,7 @@ from __future__ import annotations from http import HTTPStatus import json import logging +from typing import Any import requests import voluptuous as vol @@ -81,7 +82,7 @@ class ClicksendNotificationService(BaseNotificationService): self.language = config[CONF_LANGUAGE] self.voice = config[CONF_VOICE] - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a voice call to a user.""" data = { "messages": [ diff --git a/homeassistant/components/dovado/notify.py b/homeassistant/components/dovado/notify.py index 0b74f97d06f..b074b4cc17c 100644 --- a/homeassistant/components/dovado/notify.py +++ b/homeassistant/components/dovado/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any from homeassistant.components.notify import ATTR_TARGET, BaseNotificationService from homeassistant.core import HomeAssistant @@ -29,7 +30,7 @@ class DovadoSMSNotificationService(BaseNotificationService): """Initialize the service.""" self._client = client - def send_message(self, message, **kwargs): + def send_message(self, message: str, **kwargs: Any) -> None: """Send SMS to the specified target phone number.""" if not (target := kwargs.get(ATTR_TARGET)): _LOGGER.error("One target is required") diff --git a/homeassistant/components/facebook/notify.py b/homeassistant/components/facebook/notify.py index edd46d24982..674da78ead2 100644 --- a/homeassistant/components/facebook/notify.py +++ b/homeassistant/components/facebook/notify.py @@ -5,6 +5,7 @@ from __future__ import annotations from http import HTTPStatus import json import logging +from typing import Any import requests import voluptuous as vol @@ -46,7 +47,7 @@ class FacebookNotificationService(BaseNotificationService): """Initialize the service.""" self.page_access_token = access_token - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send some message.""" payload = {"access_token": self.page_access_token} targets = kwargs.get(ATTR_TARGET) diff --git a/homeassistant/components/flock/notify.py b/homeassistant/components/flock/notify.py index f50e04cba36..d4e8f864ee8 100644 --- a/homeassistant/components/flock/notify.py +++ b/homeassistant/components/flock/notify.py @@ -5,6 +5,7 @@ from __future__ import annotations import asyncio from http import HTTPStatus import logging +from typing import Any import voluptuous as vol @@ -47,7 +48,7 @@ class FlockNotificationService(BaseNotificationService): self._url = url self._session = session - async def async_send_message(self, message, **kwargs): + async def async_send_message(self, message: str, **kwargs: Any) -> None: """Send the message to the user.""" payload = {"text": message} diff --git a/homeassistant/components/free_mobile/notify.py b/homeassistant/components/free_mobile/notify.py index c7e3071c771..8f6613c5c23 100644 --- a/homeassistant/components/free_mobile/notify.py +++ b/homeassistant/components/free_mobile/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations from http import HTTPStatus import logging +from typing import Any from freesms import FreeClient import voluptuous as vol @@ -40,7 +41,7 @@ class FreeSMSNotificationService(BaseNotificationService): """Initialize the service.""" self.free_client = FreeClient(username, access_token) - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to the Free Mobile user cell.""" resp = self.free_client.send_sms(message) diff --git a/homeassistant/components/homematic/notify.py b/homeassistant/components/homematic/notify.py index 1f89abea5cc..b4a2692a417 100644 --- a/homeassistant/components/homematic/notify.py +++ b/homeassistant/components/homematic/notify.py @@ -2,6 +2,8 @@ from __future__ import annotations +from typing import Any + import voluptuous as vol from homeassistant.components.notify import ( @@ -60,7 +62,7 @@ class HomematicNotificationService(BaseNotificationService): self.hass = hass self.data = data - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a notification to the device.""" data = {**self.data, **kwargs.get(ATTR_DATA, {})} diff --git a/homeassistant/components/html5/notify.py b/homeassistant/components/html5/notify.py index e9ebdb9da67..859a7b7e567 100644 --- a/homeassistant/components/html5/notify.py +++ b/homeassistant/components/html5/notify.py @@ -9,6 +9,7 @@ from http import HTTPStatus import json import logging import time +from typing import Any from urllib.parse import urlparse import uuid @@ -451,7 +452,7 @@ class HTML5NotificationService(BaseNotificationService): """ await self.hass.async_add_executor_job(partial(self.dismiss, **kwargs)) - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" tag = str(uuid.uuid4()) payload = { diff --git a/homeassistant/components/joaoapps_join/notify.py b/homeassistant/components/joaoapps_join/notify.py index a3432b96b13..6a1e7bb8e6d 100644 --- a/homeassistant/components/joaoapps_join/notify.py +++ b/homeassistant/components/joaoapps_join/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any from pyjoin import get_devices, send_notification import voluptuous as vol @@ -66,7 +67,7 @@ class JoinNotificationService(BaseNotificationService): self._device_ids = device_ids self._device_names = device_names - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) data = kwargs.get(ATTR_DATA) or {} diff --git a/homeassistant/components/keba/notify.py b/homeassistant/components/keba/notify.py index 5358ba32ff9..3495e46649c 100644 --- a/homeassistant/components/keba/notify.py +++ b/homeassistant/components/keba/notify.py @@ -2,6 +2,8 @@ from __future__ import annotations +from typing import Any + from homeassistant.components.notify import ATTR_DATA, BaseNotificationService from homeassistant.core import HomeAssistant from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -27,7 +29,7 @@ class KebaNotificationService(BaseNotificationService): """Initialize the service.""" self._client = client - async def async_send_message(self, message="", **kwargs): + async def async_send_message(self, message: str = "", **kwargs: Any) -> None: """Send the message.""" text = message.replace(" ", "$") # Will be translated back by the display diff --git a/homeassistant/components/kodi/notify.py b/homeassistant/components/kodi/notify.py index 8360f74ce24..49e326334b9 100644 --- a/homeassistant/components/kodi/notify.py +++ b/homeassistant/components/kodi/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any import aiohttp import jsonrpc_async @@ -93,7 +94,7 @@ class KodiNotificationService(BaseNotificationService): self._server = jsonrpc_async.Server(self._url, **kwargs) - async def async_send_message(self, message="", **kwargs): + async def async_send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to Kodi.""" try: data = kwargs.get(ATTR_DATA) or {} diff --git a/homeassistant/components/lannouncer/notify.py b/homeassistant/components/lannouncer/notify.py index 983a5e7b32a..4b5f249a2f1 100644 --- a/homeassistant/components/lannouncer/notify.py +++ b/homeassistant/components/lannouncer/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations import logging import socket +from typing import Any from urllib.parse import urlencode import voluptuous as vol @@ -73,7 +74,7 @@ class LannouncerNotificationService(BaseNotificationService): self._host = host self._port = port - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to Lannouncer.""" data = kwargs.get(ATTR_DATA) if data is not None and ATTR_METHOD in data: diff --git a/homeassistant/components/llamalab_automate/notify.py b/homeassistant/components/llamalab_automate/notify.py index da13267aec3..94693d3faa0 100644 --- a/homeassistant/components/llamalab_automate/notify.py +++ b/homeassistant/components/llamalab_automate/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations from http import HTTPStatus import logging +from typing import Any import requests import voluptuous as vol @@ -56,7 +57,7 @@ class AutomateNotificationService(BaseNotificationService): self._recipient = recipient self._device = device - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" # Extract params from data dict diff --git a/homeassistant/components/mailgun/notify.py b/homeassistant/components/mailgun/notify.py index b839e184810..daf5eb904ab 100644 --- a/homeassistant/components/mailgun/notify.py +++ b/homeassistant/components/mailgun/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any from pymailgunner import ( Client, @@ -91,7 +92,7 @@ class MailgunNotificationService(BaseNotificationService): return False return True - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a mail to the recipient.""" subject = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) diff --git a/homeassistant/components/message_bird/notify.py b/homeassistant/components/message_bird/notify.py index c5cbe695243..4d4ffdc814e 100644 --- a/homeassistant/components/message_bird/notify.py +++ b/homeassistant/components/message_bird/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any import messagebird from messagebird.client import ErrorException @@ -55,7 +56,7 @@ class MessageBirdNotificationService(BaseNotificationService): self.sender = sender self.client = client - def send_message(self, message=None, **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a specified target.""" if not (targets := kwargs.get(ATTR_TARGET)): _LOGGER.error("No target specified") diff --git a/homeassistant/components/msteams/notify.py b/homeassistant/components/msteams/notify.py index 06f9bc42e91..47ec9f04637 100644 --- a/homeassistant/components/msteams/notify.py +++ b/homeassistant/components/msteams/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any import pymsteams import voluptuous as vol @@ -49,7 +50,7 @@ class MSTeamsNotificationService(BaseNotificationService): """Initialize the service.""" self._webhook_url = webhook_url - def send_message(self, message=None, **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to the webhook.""" teams_message = pymsteams.connectorcard(self._webhook_url) diff --git a/homeassistant/components/netgear_lte/notify.py b/homeassistant/components/netgear_lte/notify.py index 5b10398e055..8788c00ac75 100644 --- a/homeassistant/components/netgear_lte/notify.py +++ b/homeassistant/components/netgear_lte/notify.py @@ -40,7 +40,7 @@ class NetgearNotifyService(BaseNotificationService): self.modem: Modem = discovery_info["modem"] discovery_info["entry"].async_on_unload(self.async_unregister_services) - async def async_send_message(self, message="", **kwargs): + async def async_send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" if not self.modem.token: diff --git a/homeassistant/components/notify_events/notify.py b/homeassistant/components/notify_events/notify.py index bfe0e4a2a57..92628059d68 100644 --- a/homeassistant/components/notify_events/notify.py +++ b/homeassistant/components/notify_events/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations import logging import os.path +from typing import Any from notify_events import Message @@ -123,7 +124,7 @@ class NotifyEventsNotificationService(BaseNotificationService): return msg - def send_message(self, message, **kwargs): + def send_message(self, message: str, **kwargs: Any) -> None: """Send a message.""" data = kwargs.get(ATTR_DATA) or {} token = data.get(ATTR_TOKEN, self.token) diff --git a/homeassistant/components/rocketchat/notify.py b/homeassistant/components/rocketchat/notify.py index 20ae0708c15..96eda4b5609 100644 --- a/homeassistant/components/rocketchat/notify.py +++ b/homeassistant/components/rocketchat/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations from http import HTTPStatus import logging +from typing import Any from rocketchat_API.APIExceptions.RocketExceptions import ( RocketAuthenticationException, @@ -69,7 +70,7 @@ class RocketChatNotificationService(BaseNotificationService): self._room = room self._server = RocketChat(username, password, server_url=url) - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to Rocket.Chat.""" data = kwargs.get(ATTR_DATA) or {} resp = self._server.chat_post_message(message, channel=self._room, **data) diff --git a/homeassistant/components/sendgrid/notify.py b/homeassistant/components/sendgrid/notify.py index 4dbb95085cb..613329c3658 100644 --- a/homeassistant/components/sendgrid/notify.py +++ b/homeassistant/components/sendgrid/notify.py @@ -4,6 +4,7 @@ from __future__ import annotations from http import HTTPStatus import logging +from typing import Any from sendgrid import SendGridAPIClient import voluptuous as vol @@ -61,7 +62,7 @@ class SendgridNotificationService(BaseNotificationService): self._sg = SendGridAPIClient(self.api_key) - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send an email to a user via SendGrid.""" subject = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) diff --git a/homeassistant/components/sinch/notify.py b/homeassistant/components/sinch/notify.py index 8c906d26c23..47f8d6b5a87 100644 --- a/homeassistant/components/sinch/notify.py +++ b/homeassistant/components/sinch/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any from clx.xms.api import MtBatchTextSmsResult from clx.xms.client import Client @@ -67,7 +68,7 @@ class SinchNotificationService(BaseNotificationService): self.sender = config[CONF_SENDER] self.client = Client(config[CONF_SERVICE_PLAN_ID], config[CONF_API_KEY]) - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" targets = kwargs.get(ATTR_TARGET, self.default_recipients) data = kwargs.get(ATTR_DATA) or {} diff --git a/homeassistant/components/synology_chat/notify.py b/homeassistant/components/synology_chat/notify.py index 37ea3238a06..a4ae3b1aaa2 100644 --- a/homeassistant/components/synology_chat/notify.py +++ b/homeassistant/components/synology_chat/notify.py @@ -5,6 +5,7 @@ from __future__ import annotations from http import HTTPStatus import json import logging +from typing import Any import requests import voluptuous as vol @@ -51,7 +52,7 @@ class SynologyChatNotificationService(BaseNotificationService): self._resource = resource self._verify_ssl = verify_ssl - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" data = {"text": message} diff --git a/homeassistant/components/syslog/notify.py b/homeassistant/components/syslog/notify.py index dbbada65fb2..96102cc9c0a 100644 --- a/homeassistant/components/syslog/notify.py +++ b/homeassistant/components/syslog/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import syslog +from typing import Any import voluptuous as vol @@ -91,7 +92,7 @@ class SyslogNotificationService(BaseNotificationService): self._option = option self._priority = priority - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to syslog.""" title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) diff --git a/homeassistant/components/twilio_call/notify.py b/homeassistant/components/twilio_call/notify.py index 4c432e0aeb5..bcea6d6fb82 100644 --- a/homeassistant/components/twilio_call/notify.py +++ b/homeassistant/components/twilio_call/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any import urllib from twilio.base.exceptions import TwilioRestException @@ -50,7 +51,7 @@ class TwilioCallNotificationService(BaseNotificationService): self.client = twilio_client self.from_number = from_number - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Call to specified target users.""" if not (targets := kwargs.get(ATTR_TARGET)): _LOGGER.warning("At least 1 target is required") diff --git a/homeassistant/components/twilio_sms/notify.py b/homeassistant/components/twilio_sms/notify.py index a3f824f375f..24527fdaf53 100644 --- a/homeassistant/components/twilio_sms/notify.py +++ b/homeassistant/components/twilio_sms/notify.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol @@ -56,7 +57,7 @@ class TwilioSMSNotificationService(BaseNotificationService): self.client = twilio_client self.from_number = from_number - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Send SMS to specified target user cell.""" targets = kwargs.get(ATTR_TARGET) data = kwargs.get(ATTR_DATA) or {} diff --git a/homeassistant/components/twitter/notify.py b/homeassistant/components/twitter/notify.py index f94bcd54459..7799cfbb85e 100644 --- a/homeassistant/components/twitter/notify.py +++ b/homeassistant/components/twitter/notify.py @@ -9,6 +9,7 @@ import json import logging import mimetypes import os +from typing import Any from TwitterAPI import TwitterAPI import voluptuous as vol @@ -79,7 +80,7 @@ class TwitterNotificationService(BaseNotificationService): consumer_key, consumer_secret, access_token_key, access_token_secret ) - def send_message(self, message="", **kwargs): + def send_message(self, message: str = "", **kwargs: Any) -> None: """Tweet a message, optionally with media.""" data = kwargs.get(ATTR_DATA) targets = kwargs.get(ATTR_TARGET) diff --git a/homeassistant/components/xmpp/notify.py b/homeassistant/components/xmpp/notify.py index d44a826e50c..964f66f1db2 100644 --- a/homeassistant/components/xmpp/notify.py +++ b/homeassistant/components/xmpp/notify.py @@ -9,6 +9,7 @@ import mimetypes import pathlib import random import string +from typing import Any import requests import slixmpp @@ -101,7 +102,7 @@ class XmppNotificationService(BaseNotificationService): self._verify = verify self._room = room - async def async_send_message(self, message="", **kwargs): + async def async_send_message(self, message: str = "", **kwargs: Any) -> None: """Send a message to a user.""" title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) text = f"{title}: {message}" if title else message diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index ed6c697223f..5be59a0df2f 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -2314,6 +2314,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { kwargs_type="Any", return_type=None, has_async_counterpart=True, + mandatory=True, ), ], ),