Add generic Event class (#97071)

This commit is contained in:
Marc Mueller
2023-07-23 21:51:54 +02:00
committed by GitHub
parent 860a37aa65
commit bdd253328d
4 changed files with 58 additions and 33 deletions

View File

@@ -1,10 +1,12 @@
"""Typing Helpers for Home Assistant."""
from collections.abc import Mapping
from enum import Enum
from typing import Any
from typing import Any, Generic, TypeVar
import homeassistant.core
_DataT = TypeVar("_DataT")
GPSType = tuple[float, float]
ConfigType = dict[str, Any]
ContextType = homeassistant.core.Context
@@ -32,5 +34,10 @@ UNDEFINED = UndefinedType._singleton # pylint: disable=protected-access
# that may rely on them.
# In due time they will be removed.
HomeAssistantType = homeassistant.core.HomeAssistant
EventType = homeassistant.core.Event
ServiceCallType = homeassistant.core.ServiceCall
class EventType(homeassistant.core.Event, Generic[_DataT]):
"""Generic Event class to better type data."""
data: _DataT # type: ignore[assignment]