Add decorator typing [soma] (#107559)

This commit is contained in:
Marc Mueller 2024-01-10 14:13:05 +01:00 committed by GitHub
parent 402ead8df2
commit fbbe03c93c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)