From 69652ca2ca25d010f6afb1021843305b84b862c8 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 19 Aug 2024 21:13:48 +0200 Subject: [PATCH] Use PEP 695 for decorator typing with type aliases in esphome (#124234) --- homeassistant/components/esphome/entity.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/esphome/entity.py b/homeassistant/components/esphome/entity.py index 6e02f8de869..764390c861b 100644 --- a/homeassistant/components/esphome/entity.py +++ b/homeassistant/components/esphome/entity.py @@ -5,7 +5,7 @@ from __future__ import annotations 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, @@ -30,8 +30,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback 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) @@ -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. @@ -139,7 +137,7 @@ def esphome_state_property( 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.