From 92ace6c2e8adf576176b41e9e7a1561499d9039a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 28 Dec 2021 14:23:42 +0100 Subject: [PATCH] Ensure service calls are typed [s-u] (#62922) Co-authored-by: epenet --- homeassistant/components/sabnzbd/__init__.py | 4 ++-- homeassistant/components/screenlogic/services.py | 2 +- homeassistant/components/script/__init__.py | 12 ++++++------ homeassistant/components/sensibo/climate.py | 4 ++-- homeassistant/components/shopping_list/__init__.py | 14 +++++++------- homeassistant/components/snips/__init__.py | 9 +++++---- .../components/speedtestdotnet/__init__.py | 4 ++-- homeassistant/components/starline/__init__.py | 10 ++++++---- homeassistant/components/system_bridge/__init__.py | 10 +++++----- homeassistant/components/system_log/__init__.py | 4 ++-- homeassistant/components/telegram_bot/__init__.py | 3 ++- homeassistant/components/transmission/__init__.py | 9 +++++---- homeassistant/components/tts/__init__.py | 6 +++--- homeassistant/components/unifi/services.py | 4 ++-- 14 files changed, 50 insertions(+), 45 deletions(-) diff --git a/homeassistant/components/sabnzbd/__init__.py b/homeassistant/components/sabnzbd/__init__.py index f2b1ce882c7..3cb183a6e42 100644 --- a/homeassistant/components/sabnzbd/__init__.py +++ b/homeassistant/components/sabnzbd/__init__.py @@ -22,7 +22,7 @@ from homeassistant.const import ( DATA_MEGABYTES, DATA_RATE_MEGABYTES_PER_SECOND, ) -from homeassistant.core import callback +from homeassistant.core import ServiceCall, callback from homeassistant.helpers import discovery from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv @@ -225,7 +225,7 @@ def async_setup_sabnzbd(hass, sab_api, config, name): discovery.async_load_platform(hass, "sensor", DOMAIN, {}, config) ) - async def async_service_handler(service): + async def async_service_handler(service: ServiceCall) -> None: """Handle service calls.""" if service.service == SERVICE_PAUSE: await sab_api_data.async_pause_queue() diff --git a/homeassistant/components/screenlogic/services.py b/homeassistant/components/screenlogic/services.py index c046a4478fe..62027a41949 100644 --- a/homeassistant/components/screenlogic/services.py +++ b/homeassistant/components/screenlogic/services.py @@ -40,7 +40,7 @@ def async_load_screenlogic_services(hass: HomeAssistant): if hass.config_entries.async_get_entry(entry_id).domain == DOMAIN ] - async def async_set_color_mode(service_call: ServiceCall): + async def async_set_color_mode(service_call: ServiceCall) -> None: if not ( screenlogic_entry_ids := await extract_screenlogic_config_entry_ids( service_call diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index a8ffb271336..991769bd5c4 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -26,7 +26,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_ON, ) -from homeassistant.core import HomeAssistant, callback +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import extract_domain_configs import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import make_entity_service_schema @@ -170,14 +170,14 @@ async def async_setup(hass, config): if not await _async_process_config(hass, config, component): await async_get_blueprints(hass).async_populate() - async def reload_service(service): + async def reload_service(service: ServiceCall) -> None: """Call a service to reload scripts.""" if (conf := await component.async_prepare_reload()) is None: return await _async_process_config(hass, conf, component) - async def turn_on_service(service): + async def turn_on_service(service: ServiceCall) -> None: """Call a service to turn script on.""" variables = service.data.get(ATTR_VARIABLES) for script_entity in await component.async_extract_from_service(service): @@ -185,7 +185,7 @@ async def async_setup(hass, config): variables=variables, context=service.context, wait=False ) - async def turn_off_service(service): + async def turn_off_service(service: ServiceCall) -> None: """Cancel a script.""" # Stopping a script is ok to be done in parallel script_entities = await component.async_extract_from_service(service) @@ -200,7 +200,7 @@ async def async_setup(hass, config): ] ) - async def toggle_service(service): + async def toggle_service(service: ServiceCall) -> None: """Toggle a script.""" for script_entity in await component.async_extract_from_service(service): await script_entity.async_toggle(context=service.context, wait=False) @@ -266,7 +266,7 @@ async def _async_process_config(hass, config, component) -> bool: await component.async_add_entities(entities) - async def service_handler(service): + async def service_handler(service: ServiceCall) -> None: """Execute a service call to script.