Add type hint to adguard service calls (#62893)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/62896/head
epenet 2021-12-27 23:55:46 +01:00 committed by GitHub
parent e01b0a3625
commit 942f58593b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 15 deletions

View File

@ -18,7 +18,7 @@ from homeassistant.const import (
CONF_VERIFY_SSL,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -72,31 +72,27 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
async def add_url(call) -> None:
async def add_url(call: ServiceCall) -> None:
"""Service call to add a new filter subscription to AdGuard Home."""
await adguard.filtering.add_url(
allowlist=False, name=call.data.get(CONF_NAME), url=call.data.get(CONF_URL)
allowlist=False, name=call.data[CONF_NAME], url=call.data[CONF_URL]
)
async def remove_url(call) -> None:
async def remove_url(call: ServiceCall) -> None:
"""Service call to remove a filter subscription from AdGuard Home."""
await adguard.filtering.remove_url(allowlist=False, url=call.data.get(CONF_URL))
await adguard.filtering.remove_url(allowlist=False, url=call.data[CONF_URL])
async def enable_url(call) -> None:
async def enable_url(call: ServiceCall) -> None:
"""Service call to enable a filter subscription in AdGuard Home."""
await adguard.filtering.enable_url(allowlist=False, url=call.data.get(CONF_URL))
await adguard.filtering.enable_url(allowlist=False, url=call.data[CONF_URL])
async def disable_url(call) -> None:
async def disable_url(call: ServiceCall) -> None:
"""Service call to disable a filter subscription in AdGuard Home."""
await adguard.filtering.disable_url(
allowlist=False, url=call.data.get(CONF_URL)
)
await adguard.filtering.disable_url(allowlist=False, url=call.data[CONF_URL])
async def refresh(call) -> None:
async def refresh(call: ServiceCall) -> None:
"""Service call to refresh the filter subscriptions in AdGuard Home."""
await adguard.filtering.refresh(
allowlist=False, force=call.data.get(CONF_FORCE)
)
await adguard.filtering.refresh(allowlist=False, force=call.data[CONF_FORCE])
hass.services.async_register(
DOMAIN, SERVICE_ADD_URL, add_url, schema=SERVICE_ADD_URL_SCHEMA