Use new syntax for TypeVar defaults (#135780)

This commit is contained in:
Marc Mueller
2025-01-17 09:12:52 +01:00
committed by GitHub
parent 6aed2dcc0f
commit 46b17b539c
12 changed files with 35 additions and 62 deletions

View File

@@ -7,7 +7,7 @@ from collections.abc import Callable, Iterable
from datetime import timedelta
import logging
from types import ModuleType
from typing import Any, Generic, TypeVar
from typing import Any
from homeassistant import config as conf_util
from homeassistant.config_entries import ConfigEntry
@@ -37,8 +37,6 @@ from .typing import ConfigType, DiscoveryInfoType, VolDictType, VolSchemaType
DEFAULT_SCAN_INTERVAL = timedelta(seconds=15)
DATA_INSTANCES = "entity_components"
_EntityT = TypeVar("_EntityT", bound=entity.Entity, default=entity.Entity)
@bind_hass
async def async_update_entity(hass: HomeAssistant, entity_id: str) -> None:
@@ -62,7 +60,7 @@ async def async_update_entity(hass: HomeAssistant, entity_id: str) -> None:
await entity_obj.async_update_ha_state(True)
class EntityComponent(Generic[_EntityT]):
class EntityComponent[_EntityT: entity.Entity = entity.Entity]:
"""The EntityComponent manages platforms that manage entities.
An example of an entity component is 'light', which manages platforms such