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:
Marc Mueller 2024-04-08 01:28:24 +02:00 committed by GitHub
parent d007b175c5
commit a0e6fd6ec5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 182 additions and 62 deletions

View file

@ -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,