Make async_extract_entities generic (#78490)

pull/79586/head
epenet 2022-09-16 00:20:47 +02:00 committed by GitHub
parent 635ed562ee
commit 8300f8234c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -186,7 +186,7 @@ class EntityComponent(Generic[_EntityT]):
This method must be run in the event loop.
"""
return await service.async_extract_entities( # type: ignore[return-value]
return await service.async_extract_entities(
self.hass, self.entities, service_call, expand_group
)

View File

@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable, Iterable
import dataclasses
from functools import partial, wraps
import logging
from typing import TYPE_CHECKING, Any, TypedDict
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar
from typing_extensions import TypeGuard
import voluptuous as vol
@ -48,6 +48,8 @@ if TYPE_CHECKING:
from .entity import Entity
from .entity_platform import EntityPlatform
_EntityT = TypeVar("_EntityT", bound=Entity)
CONF_SERVICE_ENTITY_ID = "entity_id"
CONF_SERVICE_DATA_TEMPLATE = "data_template"
@ -276,10 +278,10 @@ def extract_entity_ids(
@bind_hass
async def async_extract_entities(
hass: HomeAssistant,
entities: Iterable[Entity],
entities: Iterable[_EntityT],
service_call: ServiceCall,
expand_group: bool = True,
) -> list[Entity]:
) -> list[_EntityT]:
"""Extract a list of entity objects from a service call.
Will convert group entity ids to the entity ids it represents.