mirror of
https://github.com/home-assistant/core
synced 2024-10-04 07:58:43 +02:00
Add types for HassJob [helpers.event] (#63675)
This commit is contained in:
parent
e74d7b22f3
commit
eb2238a9e1
@ -312,7 +312,7 @@ def _async_remove_indexed_listeners(
|
|||||||
data_key: str,
|
data_key: str,
|
||||||
listener_key: str,
|
listener_key: str,
|
||||||
storage_keys: Iterable[str],
|
storage_keys: Iterable[str],
|
||||||
job: HassJob,
|
job: HassJob[Any],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Remove a listener."""
|
"""Remove a listener."""
|
||||||
callbacks = hass.data[data_key]
|
callbacks = hass.data[data_key]
|
||||||
@ -394,7 +394,7 @@ def async_track_entity_registry_updated_event(
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_dispatch_domain_event(
|
def _async_dispatch_domain_event(
|
||||||
hass: HomeAssistant, event: Event, callbacks: dict[str, list[HassJob]]
|
hass: HomeAssistant, event: Event, callbacks: dict[str, list[HassJob[Any]]]
|
||||||
) -> None:
|
) -> None:
|
||||||
domain = split_entity_id(event.data["entity_id"])[0]
|
domain = split_entity_id(event.data["entity_id"])[0]
|
||||||
|
|
||||||
@ -1224,7 +1224,8 @@ track_same_state = threaded_listener_factory(async_track_same_state)
|
|||||||
@bind_hass
|
@bind_hass
|
||||||
def async_track_point_in_time(
|
def async_track_point_in_time(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
action: HassJob | Callable[[datetime], Awaitable[None] | None],
|
action: HassJob[Awaitable[None] | None]
|
||||||
|
| Callable[[datetime], Awaitable[None] | None],
|
||||||
point_in_time: datetime,
|
point_in_time: datetime,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that fires once after a specific point in time."""
|
"""Add a listener that fires once after a specific point in time."""
|
||||||
@ -1245,7 +1246,8 @@ track_point_in_time = threaded_listener_factory(async_track_point_in_time)
|
|||||||
@bind_hass
|
@bind_hass
|
||||||
def async_track_point_in_utc_time(
|
def async_track_point_in_utc_time(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
action: HassJob | Callable[[datetime], Awaitable[None] | None],
|
action: HassJob[Awaitable[None] | None]
|
||||||
|
| Callable[[datetime], Awaitable[None] | None],
|
||||||
point_in_time: datetime,
|
point_in_time: datetime,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that fires once after a specific point in UTC time."""
|
"""Add a listener that fires once after a specific point in UTC time."""
|
||||||
@ -1257,7 +1259,7 @@ def async_track_point_in_utc_time(
|
|||||||
cancel_callback: asyncio.TimerHandle | None = None
|
cancel_callback: asyncio.TimerHandle | None = None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def run_action(job: HassJob) -> None:
|
def run_action(job: HassJob[Awaitable[None] | None]) -> None:
|
||||||
"""Call the action."""
|
"""Call the action."""
|
||||||
nonlocal cancel_callback
|
nonlocal cancel_callback
|
||||||
|
|
||||||
@ -1297,7 +1299,8 @@ track_point_in_utc_time = threaded_listener_factory(async_track_point_in_utc_tim
|
|||||||
def async_call_later(
|
def async_call_later(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
delay: float | timedelta,
|
delay: float | timedelta,
|
||||||
action: HassJob | Callable[[datetime], Awaitable[None] | None],
|
action: HassJob[Awaitable[None] | None]
|
||||||
|
| Callable[[datetime], Awaitable[None] | None],
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that is called in <delay>."""
|
"""Add a listener that is called in <delay>."""
|
||||||
if not isinstance(delay, timedelta):
|
if not isinstance(delay, timedelta):
|
||||||
@ -1354,7 +1357,7 @@ class SunListener:
|
|||||||
"""Helper class to help listen to sun events."""
|
"""Helper class to help listen to sun events."""
|
||||||
|
|
||||||
hass: HomeAssistant = attr.ib()
|
hass: HomeAssistant = attr.ib()
|
||||||
job: HassJob = attr.ib()
|
job: HassJob[Awaitable[None] | None] = attr.ib()
|
||||||
event: str = attr.ib()
|
event: str = attr.ib()
|
||||||
offset: timedelta | None = attr.ib()
|
offset: timedelta | None = attr.ib()
|
||||||
_unsub_sun: CALLBACK_TYPE | None = attr.ib(default=None)
|
_unsub_sun: CALLBACK_TYPE | None = attr.ib(default=None)
|
||||||
|
Loading…
Reference in New Issue
Block a user