Skip to content

Commit

Permalink
Use PEP 695 for decorator typing with type aliases in esphome (#124234)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Aug 19, 2024
1 parent 89728f4 commit 69652ca
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions homeassistant/components/esphome/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Awaitable, Callable, Coroutine
import functools
import math
from typing import TYPE_CHECKING, Any, Concatenate, Generic, ParamSpec, TypeVar, cast
from typing import TYPE_CHECKING, Any, Concatenate, Generic, TypeVar, cast

from aioesphomeapi import (
APIConnectionError,
Expand All @@ -30,8 +30,6 @@
from .entry_data import ESPHomeConfigEntry, RuntimeEntryData
from .enum_mapper import EsphomeEnumMapper

_R = TypeVar("_R")
_P = ParamSpec("_P")
_InfoT = TypeVar("_InfoT", bound=EntityInfo)
_EntityT = TypeVar("_EntityT", bound="EsphomeEntity[Any,Any]")
_StateT = TypeVar("_StateT", bound=EntityState)
Expand Down Expand Up @@ -116,7 +114,7 @@ async def platform_async_setup_entry(
)


def esphome_state_property(
def esphome_state_property[_R, _EntityT: EsphomeEntity[Any, Any]](
func: Callable[[_EntityT], _R],
) -> Callable[[_EntityT], _R | None]:
"""Wrap a state property of an esphome entity.
Expand All @@ -139,7 +137,7 @@ def _wrapper(self: _EntityT) -> _R | None:
return _wrapper


def convert_api_error_ha_error(
def convert_api_error_ha_error[**_P, _R, _EntityT: EsphomeEntity[Any, Any]](
func: Callable[Concatenate[_EntityT, _P], Awaitable[None]],
) -> Callable[Concatenate[_EntityT, _P], Coroutine[Any, Any, None]]:
"""Decorate ESPHome command calls that send commands/make changes to the device.
Expand Down

0 comments on commit 69652ca

Please sign in to comment.