Add improved typing for event fire and listen methods (#114906)
* Add EventType implementation * Update integrations for EventType * Change state_changed to EventType * Fix tests * Remove runtime impact * Add tests * Move to stub file * Apply pre-commit to stub files * Fix ruff PYI checks --------- Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
d007b175c5
commit
a0e6fd6ec5
21 changed files with 182 additions and 62 deletions
|
@ -38,6 +38,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant, split_entity_id
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.util.event_type import EventType
|
||||
|
||||
from .const import (
|
||||
ATTR_MESSAGE,
|
||||
|
@ -75,7 +76,8 @@ class LogbookRun:
|
|||
|
||||
context_lookup: dict[bytes | None, Row | EventAsRow | None]
|
||||
external_events: dict[
|
||||
str, tuple[str, Callable[[LazyEventPartialState], dict[str, Any]]]
|
||||
EventType[Any] | str,
|
||||
tuple[str, Callable[[LazyEventPartialState], dict[str, Any]]],
|
||||
]
|
||||
event_cache: EventCache
|
||||
entity_name_cache: EntityNameCache
|
||||
|
@ -90,7 +92,7 @@ class EventProcessor:
|
|||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
event_types: tuple[str, ...],
|
||||
event_types: tuple[EventType[Any] | str, ...],
|
||||
entity_ids: list[str] | None = None,
|
||||
device_ids: list[str] | None = None,
|
||||
context_id: str | None = None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue