Rename bound TypeVars (#70975)
This commit is contained in:
parent
9672cddb07
commit
cdafbbe10f
5 changed files with 29 additions and 21 deletions
|
@ -9,21 +9,23 @@ from homeassistant.exceptions import HomeAssistantError
|
|||
|
||||
from .entity import PlugwiseEntity
|
||||
|
||||
_P = ParamSpec("_P")
|
||||
_PlugwiseEntityT = TypeVar("_PlugwiseEntityT", bound=PlugwiseEntity)
|
||||
_R = TypeVar("_R")
|
||||
_T = TypeVar("_T", bound=PlugwiseEntity)
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
|
||||
def plugwise_command(
|
||||
func: Callable[Concatenate[_T, _P], Awaitable[_R]]
|
||||
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R]]:
|
||||
func: Callable[Concatenate[_PlugwiseEntityT, _P], Awaitable[_R]]
|
||||
) -> Callable[Concatenate[_PlugwiseEntityT, _P], Coroutine[Any, Any, _R]]:
|
||||
"""Decorate Plugwise calls that send commands/make changes to the device.
|
||||
|
||||
A decorator that wraps the passed in function, catches Plugwise errors,
|
||||
and requests an coordinator update to update status of the devices asap.
|
||||
"""
|
||||
|
||||
async def handler(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> _R:
|
||||
async def handler(
|
||||
self: _PlugwiseEntityT, *args: _P.args, **kwargs: _P.kwargs
|
||||
) -> _R:
|
||||
try:
|
||||
return await func(self, *args, **kwargs)
|
||||
except PlugwiseException as error:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue