Add decorator typing [soma] (#107559)
This commit is contained in:
parent
402ead8df2
commit
fbbe03c93c
1 changed files with 10 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue