diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index 9381b7951d68ea..38762fbc648918 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -2,11 +2,11 @@ from __future__ import annotations import asyncio -from collections.abc import Coroutine +from collections.abc import Callable, Coroutine from http import HTTPStatus import logging import os -from typing import Any +from typing import Any, ParamSpec import aiohttp from yarl import URL @@ -23,6 +23,8 @@ from .const import ATTR_DISCOVERY, DOMAIN, X_HASS_SOURCE +_P = ParamSpec("_P") + _LOGGER = logging.getLogger(__name__) @@ -30,10 +32,12 @@ class HassioAPIError(RuntimeError): """Return if a API trow a error.""" -def _api_bool(funct): +def _api_bool( + funct: Callable[_P, Coroutine[Any, Any, dict[str, Any]]], +) -> Callable[_P, Coroutine[Any, Any, bool]]: """Return a boolean.""" - async def _wrapper(*argv, **kwargs): + async def _wrapper(*argv: _P.args, **kwargs: _P.kwargs) -> bool: """Wrap function.""" try: data = await funct(*argv, **kwargs) @@ -44,10 +48,12 @@ async def _wrapper(*argv, **kwargs): return _wrapper -def api_data(funct): +def api_data( + funct: Callable[_P, Coroutine[Any, Any, dict[str, Any]]], +) -> Callable[_P, Coroutine[Any, Any, Any]]: """Return data of an api.""" - async def _wrapper(*argv, **kwargs): + async def _wrapper(*argv: _P.args, **kwargs: _P.kwargs) -> Any: """Wrap function.""" data = await funct(*argv, **kwargs) if data["result"] == "ok": @@ -80,7 +86,7 @@ async def async_get_addon_store_info(hass: HomeAssistant, slug: str) -> dict: @bind_hass -async def async_update_diagnostics(hass: HomeAssistant, diagnostics: bool) -> dict: +async def async_update_diagnostics(hass: HomeAssistant, diagnostics: bool) -> bool: """Update Supervisor diagnostics toggle. The caller of the function should handle HassioAPIError. @@ -255,7 +261,7 @@ async def async_update_core( @bind_hass @_api_bool -async def async_apply_suggestion(hass: HomeAssistant, suggestion_uuid: str) -> bool: +async def async_apply_suggestion(hass: HomeAssistant, suggestion_uuid: str) -> dict: """Apply a suggestion from supervisor's resolution center. The caller of the function should handle HassioAPIError.