diff --git a/homeassistant/components/apprise/notify.py b/homeassistant/components/apprise/notify.py index 2aeeb62b00b..b215f93aeb1 100644 --- a/homeassistant/components/apprise/notify.py +++ b/homeassistant/components/apprise/notify.py @@ -1,4 +1,6 @@ """Apprise platform for notify component.""" +from __future__ import annotations + import logging import apprise @@ -12,7 +14,9 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import CONF_URL +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) @@ -26,7 +30,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, +) -> AppriseNotificationService | None: """Get the Apprise notification service.""" # Create our Apprise Instance (reference our asset) a_obj = apprise.Apprise() diff --git a/homeassistant/components/aws/notify.py b/homeassistant/components/aws/notify.py index e11b9db6c5e..2e3ea341f60 100644 --- a/homeassistant/components/aws/notify.py +++ b/homeassistant/components/aws/notify.py @@ -1,4 +1,6 @@ """AWS platform for notify component.""" +from __future__ import annotations + import asyncio import base64 import json @@ -20,7 +22,9 @@ from homeassistant.const import ( CONF_PROFILE_NAME, CONF_SERVICE, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers.json import JSONEncoder +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import CONF_CONTEXT, CONF_CREDENTIAL_NAME, CONF_REGION, DATA_SESSIONS @@ -33,7 +37,11 @@ async def get_available_regions(hass, service): return await session.get_available_regions(service) -async def async_get_service(hass, config, discovery_info=None): +async def async_get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> AWSNotify | None: """Get the AWS notification service.""" if discovery_info is None: _LOGGER.error("Please config aws notify platform in aws component") diff --git a/homeassistant/components/circuit/notify.py b/homeassistant/components/circuit/notify.py index 634ecb4f859..836c4118df0 100644 --- a/homeassistant/components/circuit/notify.py +++ b/homeassistant/components/circuit/notify.py @@ -1,15 +1,23 @@ """Unify Circuit platform for notify component.""" +from __future__ import annotations + import logging from circuit_webhook import Circuit from homeassistant.components.notify import BaseNotificationService from homeassistant.const import CONF_URL +from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> CircuitNotificationService | None: """Get the Unify Circuit notification service.""" if discovery_info is None: return None diff --git a/homeassistant/components/cisco_webex_teams/notify.py b/homeassistant/components/cisco_webex_teams/notify.py index 271d58fcc8e..be8710c7096 100644 --- a/homeassistant/components/cisco_webex_teams/notify.py +++ b/homeassistant/components/cisco_webex_teams/notify.py @@ -1,4 +1,6 @@ """Cisco Webex Teams notify component.""" +from __future__ import annotations + import logging import voluptuous as vol @@ -10,7 +12,9 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import CONF_TOKEN +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) @@ -21,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, +) -> CiscoWebexTeamsNotificationService | None: """Get the CiscoWebexTeams notification service.""" client = WebexTeamsAPI(access_token=config[CONF_TOKEN]) diff --git a/homeassistant/components/clicksend_tts/notify.py b/homeassistant/components/clicksend_tts/notify.py index 5ff38c41fc9..8eb3782415e 100644 --- a/homeassistant/components/clicksend_tts/notify.py +++ b/homeassistant/components/clicksend_tts/notify.py @@ -1,4 +1,6 @@ """clicksend_tts platform for notify component.""" +from __future__ import annotations + from http import HTTPStatus import json import logging @@ -14,7 +16,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__) @@ -49,7 +53,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, +) -> ClicksendNotificationService | None: """Get the ClickSend notification service.""" if not _authenticate(config): _LOGGER.error("You are not authorized to access ClickSend") diff --git a/homeassistant/components/dovado/notify.py b/homeassistant/components/dovado/notify.py index c599ad918e8..ba7dcf6d486 100644 --- a/homeassistant/components/dovado/notify.py +++ b/homeassistant/components/dovado/notify.py @@ -1,14 +1,22 @@ """Support for SMS notifications from the Dovado router.""" +from __future__ import annotations + import logging from homeassistant.components.notify import ATTR_TARGET, BaseNotificationService +from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import DOMAIN as DOVADO_DOMAIN _LOGGER = logging.getLogger(__name__) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> DovadoSMSNotificationService: """Get the Dovado Router SMS notification service.""" return DovadoSMSNotificationService(hass.data[DOVADO_DOMAIN].client) diff --git a/homeassistant/components/ecobee/notify.py b/homeassistant/components/ecobee/notify.py index 75d1316f0e3..1372cc9f64d 100644 --- a/homeassistant/components/ecobee/notify.py +++ b/homeassistant/components/ecobee/notify.py @@ -1,11 +1,18 @@ """Support for Ecobee Send Message service.""" +from __future__ import annotations from homeassistant.components.notify import ATTR_TARGET, BaseNotificationService +from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import DOMAIN -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> EcobeeNotificationService | None: """Get the Ecobee notification service.""" if discovery_info is None: return None diff --git a/homeassistant/components/facebook/notify.py b/homeassistant/components/facebook/notify.py index e205e1a66cc..2600bbd2d9c 100644 --- a/homeassistant/components/facebook/notify.py +++ b/homeassistant/components/facebook/notify.py @@ -1,4 +1,6 @@ """Facebook platform for notify component.""" +from __future__ import annotations + from http import HTTPStatus import json import logging @@ -13,7 +15,9 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import 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__) @@ -25,7 +29,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, +) -> FacebookNotificationService: """Get the Facebook notification service.""" return FacebookNotificationService(config[CONF_PAGE_ACCESS_TOKEN]) diff --git a/homeassistant/components/flock/notify.py b/homeassistant/components/flock/notify.py index ee89937599a..5ac340400af 100644 --- a/homeassistant/components/flock/notify.py +++ b/homeassistant/components/flock/notify.py @@ -1,4 +1,6 @@ """Flock platform for notify component.""" +from __future__ import annotations + import asyncio from http import HTTPStatus import logging @@ -8,8 +10,10 @@ import voluptuous as vol from homeassistant.components.notify import PLATFORM_SCHEMA, BaseNotificationService from homeassistant.const import CONF_ACCESS_TOKEN +from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) _RESOURCE = "https://api.flock.com/hooks/sendMessage/" @@ -17,7 +21,11 @@ _RESOURCE = "https://api.flock.com/hooks/sendMessage/" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_ACCESS_TOKEN): cv.string}) -async def async_get_service(hass, config, discovery_info=None): +async def async_get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> FlockNotificationService: """Get the Flock notification service.""" access_token = config.get(CONF_ACCESS_TOKEN) url = f"{_RESOURCE}{access_token}" diff --git a/homeassistant/components/free_mobile/notify.py b/homeassistant/components/free_mobile/notify.py index 61733237807..9a1d8c99e19 100644 --- a/homeassistant/components/free_mobile/notify.py +++ b/homeassistant/components/free_mobile/notify.py @@ -1,4 +1,6 @@ """Support for Free Mobile SMS platform.""" +from __future__ import annotations + from http import HTTPStatus import logging @@ -7,7 +9,9 @@ import voluptuous as vol from homeassistant.components.notify import PLATFORM_SCHEMA, BaseNotificationService from homeassistant.const import CONF_ACCESS_TOKEN, CONF_USERNAME +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) @@ -16,7 +20,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, +) -> FreeSMSNotificationService: """Get the Free Mobile SMS notification service.""" return FreeSMSNotificationService(config[CONF_USERNAME], config[CONF_ACCESS_TOKEN]) diff --git a/homeassistant/components/homematic/notify.py b/homeassistant/components/homematic/notify.py index a8ae59d4c31..33a06336104 100644 --- a/homeassistant/components/homematic/notify.py +++ b/homeassistant/components/homematic/notify.py @@ -1,4 +1,6 @@ """Notification support for Homematic.""" +from __future__ import annotations + import voluptuous as vol from homeassistant.components.notify import ( @@ -6,8 +8,10 @@ from homeassistant.components.notify import ( PLATFORM_SCHEMA, BaseNotificationService, ) +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv import homeassistant.helpers.template as template_helper +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import ( ATTR_ADDRESS, @@ -30,7 +34,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, +) -> HomematicNotificationService: """Get the Homematic notification service.""" data = { ATTR_ADDRESS: config[ATTR_ADDRESS], diff --git a/homeassistant/components/html5/notify.py b/homeassistant/components/html5/notify.py index 30fa5b749ca..09de0c37bb4 100644 --- a/homeassistant/components/html5/notify.py +++ b/homeassistant/components/html5/notify.py @@ -1,4 +1,6 @@ """HTML5 Push Messaging notification service.""" +from __future__ import annotations + from contextlib import suppress from datetime import datetime, timedelta from functools import partial @@ -27,9 +29,10 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import ATTR_NAME, URL_ROOT -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util import ensure_unique_string from homeassistant.util.json import load_json, save_json @@ -161,7 +164,11 @@ HTML5_SHOWNOTIFICATION_PARAMETERS = ( ) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> HTML5NotificationService | None: """Get the HTML5 push notification service.""" json_path = hass.config.path(REGISTRATIONS_FILE) diff --git a/homeassistant/components/ios/notify.py b/homeassistant/components/ios/notify.py index 12fe5ba5f5e..e9926c48181 100644 --- a/homeassistant/components/ios/notify.py +++ b/homeassistant/components/ios/notify.py @@ -1,4 +1,6 @@ """Support for iOS push notifications.""" +from __future__ import annotations + from http import HTTPStatus import logging @@ -12,6 +14,8 @@ from homeassistant.components.notify import ( ATTR_TITLE_DEFAULT, BaseNotificationService, ) +from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType import homeassistant.util.dt as dt_util from .. import ios @@ -43,7 +47,11 @@ def log_rate_limits(hass, target, resp, level=20): ) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> iOSNotificationService | None: """Get the iOS notification service.""" if "notify.ios" not in hass.config.components: # Need this to enable requirements checking in the app. diff --git a/homeassistant/components/keba/notify.py b/homeassistant/components/keba/notify.py index e0c37efec51..78b3976f656 100644 --- a/homeassistant/components/keba/notify.py +++ b/homeassistant/components/keba/notify.py @@ -1,10 +1,18 @@ """Support for Keba notifications.""" +from __future__ import annotations + from homeassistant.components.notify import ATTR_DATA, BaseNotificationService +from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import DOMAIN -async def async_get_service(hass, config, discovery_info=None): +async def async_get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> KebaNotificationService: """Return the notify service.""" client = hass.data[DOMAIN] diff --git a/homeassistant/components/lannouncer/notify.py b/homeassistant/components/lannouncer/notify.py index c474bbe8c67..eb89ac416f8 100644 --- a/homeassistant/components/lannouncer/notify.py +++ b/homeassistant/components/lannouncer/notify.py @@ -1,4 +1,6 @@ """Lannouncer platform for notify component.""" +from __future__ import annotations + import logging import socket from urllib.parse import urlencode @@ -11,7 +13,9 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType ATTR_METHOD = "method" ATTR_METHOD_DEFAULT = "speak" @@ -29,7 +33,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( _LOGGER = logging.getLogger(__name__) -def get_service(hass, config, discovery_info=None): +def get_service( + hass: HomeAssistant, + config: ConfigType, + discovery_info: DiscoveryInfoType | None = None, +) -> LannouncerNotificationService: """Get the Lannouncer notification service.""" host = config.get(CONF_HOST) port = config.get(CONF_PORT) diff --git a/homeassistant/components/llamalab_automate/notify.py b/homeassistant/components/llamalab_automate/notify.py index af0271e107d..8361d65725c 100644 --- a/homeassistant/components/llamalab_automate/notify.py +++ b/homeassistant/components/llamalab_automate/notify.py @@ -1,4 +1,6 @@ """LlamaLab Automate notification service.""" +from __future__ import annotations + from http import HTTPStatus import logging @@ -11,7 +13,9 @@ from homeassistant.components.notify import ( BaseNotificationService, ) from homeassistant.const import CONF_API_KEY, CONF_DEVICE +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) _RESOURCE = "https://llamalab.com/automate/cloud/message" @@ -29,7 +33,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, +) -> AutomateNotificationService: """Get the LlamaLab Automate notification service.""" secret = config.get(CONF_API_KEY) recipient = config.get(CONF_TO)