Ensure admin service calls are typed (#63093)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-30 21:12:40 +01:00 committed by GitHub
parent 34e732ebc1
commit 803eaa8e22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 24 deletions

View file

@ -39,7 +39,7 @@ async def async_setup_ha_cast(
else:
refresh_token = await hass.auth.async_create_refresh_token(user)
async def handle_show_view(call: core.ServiceCall):
async def handle_show_view(call: core.ServiceCall) -> None:
"""Handle a Show View service call."""
hass_url = get_url(hass, require_ssl=True, prefer_external=True)

View file

@ -13,7 +13,7 @@ from homeassistant.const import (
CONF_REGION,
EVENT_HOMEASSISTANT_STOP,
)
from homeassistant.core import callback
from homeassistant.core import ServiceCall, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entityfilter
from homeassistant.loader import bind_hass
@ -197,7 +197,7 @@ async def async_setup(hass, config):
_remote_handle_prefs_updated(cloud)
async def _service_handler(service):
async def _service_handler(service: ServiceCall) -> None:
"""Handle service for cloud."""
if service.service == SERVICE_REMOTE_CONNECT:
await prefs.async_update(remote_enabled=True)

View file

@ -136,7 +136,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
ha.DOMAIN, SERVICE_TOGGLE, async_handle_turn_service, schema=service_schema
)
async def async_handle_core_service(call):
async def async_handle_core_service(call: ha.ServiceCall) -> None:
"""Service handler for handling core services."""
if call.service in SHUTDOWN_SERVICES and recorder.async_migration_in_progress(
hass
@ -220,7 +220,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
schema=SCHEMA_UPDATE_ENTITY,
)
async def async_handle_reload_config(call):
async def async_handle_reload_config(call: ha.ServiceCall) -> None:
"""Service handler for reloading core config."""
try:
conf = await conf_util.async_hass_config_yaml(hass)
@ -235,7 +235,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG, async_handle_reload_config
)
async def async_set_location(call):
async def async_set_location(call: ha.ServiceCall) -> None:
"""Service handler to set location."""
await hass.config.async_update(
latitude=call.data[ATTR_LATITUDE], longitude=call.data[ATTR_LONGITUDE]
@ -248,7 +248,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
vol.Schema({ATTR_LATITUDE: cv.latitude, ATTR_LONGITUDE: cv.longitude}),
)
async def async_handle_reload_config_entry(call):
async def async_handle_reload_config_entry(call: ha.ServiceCall) -> None:
"""Service handler for reloading a config entry."""
reload_entries = set()
if ATTR_ENTRY_ID in call.data:

View file

@ -417,7 +417,7 @@ def _async_register_events_and_services(hass: HomeAssistant):
schema=UNPAIR_SERVICE_SCHEMA,
)
async def _handle_homekit_reload(service):
async def _handle_homekit_reload(service: ServiceCall) -> None:
"""Handle start HomeKit service call."""
config = await async_integration_yaml_config(hass, DOMAIN)

View file

@ -336,7 +336,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.bus.async_listen(EVENT_USER_REMOVED, _handle_user_removed)
async def async_reload_yaml(call: ServiceCall):
async def async_reload_yaml(call: ServiceCall) -> None:
"""Reload YAML."""
conf = await entity_component.async_prepare_reload(skip_reset=True)
if conf is None:

View file

@ -56,15 +56,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
lock = asyncio.Lock()
domain_data = hass.data[DOMAIN] = {}
async def _async_run_profile(call: ServiceCall):
async def _async_run_profile(call: ServiceCall) -> None:
async with lock:
await _async_generate_profile(hass, call)
async def _async_run_memory_profile(call: ServiceCall):
async def _async_run_memory_profile(call: ServiceCall) -> None:
async with lock:
await _async_generate_memory_profile(hass, call)
async def _async_start_log_objects(call: ServiceCall):
async def _async_start_log_objects(call: ServiceCall) -> None:
if LOG_INTERVAL_SUB in domain_data:
domain_data[LOG_INTERVAL_SUB]()
@ -78,14 +78,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass, _log_objects, call.data[CONF_SCAN_INTERVAL]
)
async def _async_stop_log_objects(call: ServiceCall):
async def _async_stop_log_objects(call: ServiceCall) -> None:
if LOG_INTERVAL_SUB not in domain_data:
return
hass.components.persistent_notification.async_dismiss("profile_object_logging")
domain_data.pop(LOG_INTERVAL_SUB)()
def _dump_log_objects(call: ServiceCall):
def _dump_log_objects(call: ServiceCall) -> None:
obj_type = call.data[CONF_TYPE]
_LOGGER.critical(

View file

@ -11,7 +11,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_START,
SERVICE_RELOAD,
)
from homeassistant.core import CoreState, Event, callback
from homeassistant.core import CoreState, Event, ServiceCall, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import (
discovery,
@ -31,7 +31,7 @@ async def async_setup(hass, config):
if DOMAIN in config:
await _process_config(hass, config)
async def _reload_config(call: Event) -> None:
async def _reload_config(call: Event | ServiceCall) -> None:
"""Reload top-level + platforms."""
try:
unprocessed_conf = await conf_util.async_hass_config_yaml(hass)

View file

@ -14,7 +14,7 @@ import zigpy.zdo.types as zdo_types
from homeassistant.components import websocket_api
from homeassistant.const import ATTR_COMMAND, ATTR_NAME
from homeassistant.core import callback
from homeassistant.core import ServiceCall, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -945,7 +945,7 @@ def async_load_api(hass):
zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
application_controller = zha_gateway.application_controller
async def permit(service):
async def permit(service: ServiceCall) -> None:
"""Allow devices to join this network."""
duration = service.data[ATTR_DURATION]
ieee = service.data.get(ATTR_IEEE)
@ -976,7 +976,7 @@ def async_load_api(hass):
DOMAIN, SERVICE_PERMIT, permit, schema=SERVICE_SCHEMAS[SERVICE_PERMIT]
)
async def remove(service):
async def remove(service: ServiceCall) -> None:
"""Remove a node from the network."""
ieee = service.data[ATTR_IEEE]
zha_gateway: ZhaGatewayType = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
@ -994,7 +994,7 @@ def async_load_api(hass):
DOMAIN, SERVICE_REMOVE, remove, schema=SERVICE_SCHEMAS[IEEE_SERVICE]
)
async def set_zigbee_cluster_attributes(service):
async def set_zigbee_cluster_attributes(service: ServiceCall) -> None:
"""Set zigbee attribute for cluster on zha entity."""
ieee = service.data.get(ATTR_IEEE)
endpoint_id = service.data.get(ATTR_ENDPOINT_ID)
@ -1041,7 +1041,7 @@ def async_load_api(hass):
schema=SERVICE_SCHEMAS[SERVICE_SET_ZIGBEE_CLUSTER_ATTRIBUTE],
)
async def issue_zigbee_cluster_command(service):
async def issue_zigbee_cluster_command(service: ServiceCall) -> None:
"""Issue command on zigbee cluster on zha entity."""
ieee = service.data.get(ATTR_IEEE)
endpoint_id = service.data.get(ATTR_ENDPOINT_ID)
@ -1092,7 +1092,7 @@ def async_load_api(hass):
schema=SERVICE_SCHEMAS[SERVICE_ISSUE_ZIGBEE_CLUSTER_COMMAND],
)
async def issue_zigbee_group_command(service):
async def issue_zigbee_group_command(service: ServiceCall) -> None:
"""Issue command on zigbee cluster on a zigbee group."""
group_id = service.data.get(ATTR_GROUP)
cluster_id = service.data.get(ATTR_CLUSTER_ID)
@ -1138,7 +1138,7 @@ def async_load_api(hass):
}
return cluster_channels.get(CHANNEL_IAS_WD)
async def warning_device_squawk(service):
async def warning_device_squawk(service: ServiceCall) -> None:
"""Issue the squawk command for an IAS warning device."""
ieee = service.data[ATTR_IEEE]
mode = service.data.get(ATTR_WARNING_DEVICE_MODE)
@ -1177,7 +1177,7 @@ def async_load_api(hass):
schema=SERVICE_SCHEMAS[SERVICE_WARNING_DEVICE_SQUAWK],
)
async def warning_device_warn(service):
async def warning_device_warn(service: ServiceCall) -> None:
"""Issue the warning command for an IAS warning device."""
ieee = service.data[ATTR_IEEE]
mode = service.data.get(ATTR_WARNING_DEVICE_MODE)