From fbbe03c93c882173f4bb780051e803703f5cf745 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:13:05 +0100 Subject: [PATCH] Add decorator typing [soma] (#107559) --- homeassistant/components/soma/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/soma/__init__.py b/homeassistant/components/soma/__init__.py index aa948703118..bbcc29d7853 100644 --- a/homeassistant/components/soma/__init__.py +++ b/homeassistant/components/soma/__init__.py @@ -1,5 +1,9 @@ """Support for Soma Smartshades.""" +from __future__ import annotations + +from collections.abc import Callable, Coroutine import logging +from typing import Any, TypeVar from api.soma_api import SomaApi from requests import RequestException @@ -17,6 +21,8 @@ from homeassistant.helpers.typing import ConfigType from .const import API, DOMAIN, HOST, PORT from .utils import is_api_response_success +_SomaEntityT = TypeVar("_SomaEntityT", bound="SomaEntity") + _LOGGER = logging.getLogger(__name__) DEVICES = "devices" @@ -69,10 +75,12 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) -def soma_api_call(api_call): +def soma_api_call( + api_call: Callable[[_SomaEntityT], Coroutine[Any, Any, dict]], +) -> Callable[[_SomaEntityT], Coroutine[Any, Any, dict]]: """Soma api call decorator.""" - async def inner(self) -> dict: + async def inner(self: _SomaEntityT) -> dict: response = {} try: response_from_api = await api_call(self)