Fix Python 3.12 compatibility by converting PEP 695 syntax to traditional Generic syntax

Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-05 11:11:54 +00:00
parent 6bba03e261
commit e9e7b07252

View File

@@ -36,7 +36,9 @@ from .typing import UNDEFINED, UndefinedType
REQUEST_REFRESH_DEFAULT_COOLDOWN = 10
REQUEST_REFRESH_DEFAULT_IMMEDIATE = True
_DataT = TypeVar("_DataT", default=dict[str, Any])
_DataT = TypeVar("_DataT")
_BaseDataUpdateCoordinatorT = TypeVar("_BaseDataUpdateCoordinatorT")
_DataUpdateCoordinatorT = TypeVar("_DataUpdateCoordinatorT")
class UpdateFailed(HomeAssistantError):
@@ -539,9 +541,7 @@ class TimestampDataUpdateCoordinator(DataUpdateCoordinator[_DataT]):
self.last_update_success_time = utcnow()
class BaseCoordinatorEntity[
_BaseDataUpdateCoordinatorT: BaseDataUpdateCoordinatorProtocol
](entity.Entity):
class BaseCoordinatorEntity(entity.Entity, Generic[_BaseDataUpdateCoordinatorT]):
"""Base class for all Coordinator entities."""
def __init__(
@@ -578,11 +578,7 @@ class BaseCoordinatorEntity[
"""
class CoordinatorEntity[
_DataUpdateCoordinatorT: DataUpdateCoordinator[Any] = DataUpdateCoordinator[
dict[str, Any]
]
](BaseCoordinatorEntity[_DataUpdateCoordinatorT]):
class CoordinatorEntity(BaseCoordinatorEntity[_DataUpdateCoordinatorT], Generic[_DataUpdateCoordinatorT]):
"""A class for entities using DataUpdateCoordinator."""
def __init__(