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
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
|
||||
from enum import StrEnum
|
||||
from functools import partial
|
||||
from typing import Final
|
||||
from typing import TYPE_CHECKING, Final
|
||||
|
||||
from .helpers.deprecation import (
|
||||
DeprecatedConstant,
|
||||
|
@ -13,8 +13,12 @@ from .helpers.deprecation import (
|
|||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
from .util.event_type import EventType
|
||||
from .util.signal_type import SignalType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core import EventStateChangedData
|
||||
|
||||
APPLICATION_NAME: Final = "HomeAssistant"
|
||||
MAJOR_VERSION: Final = 2024
|
||||
MINOR_VERSION: Final = 5
|
||||
|
@ -306,7 +310,7 @@ EVENT_LOGBOOK_ENTRY: Final = "logbook_entry"
|
|||
EVENT_LOGGING_CHANGED: Final = "logging_changed"
|
||||
EVENT_SERVICE_REGISTERED: Final = "service_registered"
|
||||
EVENT_SERVICE_REMOVED: Final = "service_removed"
|
||||
EVENT_STATE_CHANGED: Final = "state_changed"
|
||||
EVENT_STATE_CHANGED: EventType[EventStateChangedData] = EventType("state_changed")
|
||||
EVENT_STATE_REPORTED: Final = "state_reported"
|
||||
EVENT_THEMES_UPDATED: Final = "themes_updated"
|
||||
EVENT_PANELS_UPDATED: Final = "panels_updated"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue