mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve notify typing (#78575)
This commit is contained in:
parent
fbd265aa2d
commit
383c83d15f
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import Any, Optional, Protocol, cast
|
from typing import Any, Optional, Protocol, cast
|
||||||
|
|
||||||
@ -162,9 +162,11 @@ async def async_reload(hass: HomeAssistant, integration_name: str) -> None:
|
|||||||
if not _async_integration_has_notify_services(hass, integration_name):
|
if not _async_integration_has_notify_services(hass, integration_name):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
notify_services: list[BaseNotificationService] = hass.data[NOTIFY_SERVICES][
|
||||||
|
integration_name
|
||||||
|
]
|
||||||
tasks = [
|
tasks = [
|
||||||
notify_service.async_register_services()
|
notify_service.async_register_services() for notify_service in notify_services
|
||||||
for notify_service in hass.data[NOTIFY_SERVICES][integration_name]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
@ -173,15 +175,20 @@ async def async_reload(hass: HomeAssistant, integration_name: str) -> None:
|
|||||||
@bind_hass
|
@bind_hass
|
||||||
async def async_reset_platform(hass: HomeAssistant, integration_name: str) -> None:
|
async def async_reset_platform(hass: HomeAssistant, integration_name: str) -> None:
|
||||||
"""Unregister notify services for an integration."""
|
"""Unregister notify services for an integration."""
|
||||||
if NOTIFY_DISCOVERY_DISPATCHER in hass.data:
|
notify_discovery_dispatcher: Callable[[], None] | None = hass.data.get(
|
||||||
hass.data[NOTIFY_DISCOVERY_DISPATCHER]()
|
NOTIFY_DISCOVERY_DISPATCHER
|
||||||
|
)
|
||||||
|
if notify_discovery_dispatcher:
|
||||||
|
notify_discovery_dispatcher()
|
||||||
hass.data[NOTIFY_DISCOVERY_DISPATCHER] = None
|
hass.data[NOTIFY_DISCOVERY_DISPATCHER] = None
|
||||||
if not _async_integration_has_notify_services(hass, integration_name):
|
if not _async_integration_has_notify_services(hass, integration_name):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
notify_services: list[BaseNotificationService] = hass.data[NOTIFY_SERVICES][
|
||||||
|
integration_name
|
||||||
|
]
|
||||||
tasks = [
|
tasks = [
|
||||||
notify_service.async_unregister_services()
|
notify_service.async_unregister_services() for notify_service in notify_services
|
||||||
for notify_service in hass.data[NOTIFY_SERVICES][integration_name]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user