Use PEP 695 for decorator typing with type aliases in zha (#124235)

This commit is contained in:
Erik Montnemery 2024-09-06 16:52:03 +02:00 committed by GitHub
parent 33814d1180
commit e3e48ff9b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,7 @@ import logging
import re
import time
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Concatenate, NamedTuple, ParamSpec, TypeVar, cast
from typing import TYPE_CHECKING, Any, Concatenate, NamedTuple, cast
from zoneinfo import ZoneInfo
import voluptuous as vol
@ -172,9 +172,6 @@ if TYPE_CHECKING:
_LogFilterType = Filter | Callable[[LogRecord], bool]
_P = ParamSpec("_P")
_EntityT = TypeVar("_EntityT", bound="ZHAEntity")
_LOGGER = logging.getLogger(__name__)
DEBUG_COMP_BELLOWS = "bellows"
@ -1277,7 +1274,7 @@ def create_zha_config(hass: HomeAssistant, ha_zha_data: HAZHAData) -> ZHAData:
)
def convert_zha_error_to_ha_error(
def convert_zha_error_to_ha_error[**_P, _EntityT: ZHAEntity](
func: Callable[Concatenate[_EntityT, _P], Awaitable[None]],
) -> Callable[Concatenate[_EntityT, _P], Coroutine[Any, Any, None]]:
"""Decorate ZHA commands and re-raises ZHAException as HomeAssistantError."""