mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Improve roku error decorator typing (#70992)
This commit is contained in:
parent
cf90e34776
commit
7649b5e6c9
@ -13,7 +13,7 @@ from .entity import RokuEntity
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
_T = TypeVar("_T", bound=RokuEntity)
|
_RokuEntityT = TypeVar("_RokuEntityT", bound=RokuEntity)
|
||||||
_P = ParamSpec("_P")
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
|
|
||||||
@ -25,14 +25,21 @@ def format_channel_name(channel_number: str, channel_name: str | None = None) ->
|
|||||||
return channel_number
|
return channel_number
|
||||||
|
|
||||||
|
|
||||||
def roku_exception_handler(ignore_timeout: bool = False) -> Callable[..., Callable]:
|
def roku_exception_handler(
|
||||||
|
ignore_timeout: bool = False,
|
||||||
|
) -> Callable[
|
||||||
|
[Callable[Concatenate[_RokuEntityT, _P], Awaitable[Any]]],
|
||||||
|
Callable[Concatenate[_RokuEntityT, _P], Coroutine[Any, Any, None]],
|
||||||
|
]:
|
||||||
"""Decorate Roku calls to handle Roku exceptions."""
|
"""Decorate Roku calls to handle Roku exceptions."""
|
||||||
|
|
||||||
def decorator(
|
def decorator(
|
||||||
func: Callable[Concatenate[_T, _P], Awaitable[None]],
|
func: Callable[Concatenate[_RokuEntityT, _P], Awaitable[Any]],
|
||||||
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, None]]:
|
) -> Callable[Concatenate[_RokuEntityT, _P], Coroutine[Any, Any, None]]:
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
async def wrapper(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> None:
|
async def wrapper(
|
||||||
|
self: _RokuEntityT, *args: _P.args, **kwargs: _P.kwargs
|
||||||
|
) -> None:
|
||||||
try:
|
try:
|
||||||
await func(self, *args, **kwargs)
|
await func(self, *args, **kwargs)
|
||||||
except RokuConnectionTimeoutError as error:
|
except RokuConnectionTimeoutError as error:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user