Replace EventType with Event [missing] (#112753)

This commit is contained in:
Marc Mueller 2024-03-08 21:56:42 +01:00 committed by GitHub
parent c7eabd95e6
commit cef20506dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 28 additions and 35 deletions

View file

@ -5,9 +5,8 @@ from __future__ import annotations
from collections.abc import Callable
from homeassistant.components.logbook import LOGBOOK_ENTRY_MESSAGE, LOGBOOK_ENTRY_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers.device_registry import async_get
from homeassistant.helpers.typing import EventType
from .const import BTHOME_BLE_EVENT, DOMAIN, BTHomeBleEvent
@ -16,14 +15,14 @@ from .const import BTHOME_BLE_EVENT, DOMAIN, BTHomeBleEvent
def async_describe_events(
hass: HomeAssistant,
async_describe_event: Callable[
[str, str, Callable[[EventType[BTHomeBleEvent]], dict[str, str]]], None
[str, str, Callable[[Event[BTHomeBleEvent]], dict[str, str]]], None
],
) -> None:
"""Describe logbook events."""
dr = async_get(hass)
@callback
def async_describe_bthome_event(event: EventType[BTHomeBleEvent]) -> dict[str, str]:
def async_describe_bthome_event(event: Event[BTHomeBleEvent]) -> dict[str, str]:
"""Describe bthome logbook event."""
data = event.data
device = dr.async_get(data["device_id"])

View file

@ -43,7 +43,6 @@ from homeassistant.helpers.event import (
EventStateChangedData,
async_track_state_added_domain,
)
from homeassistant.helpers.typing import EventType
from homeassistant.util.json import JsonObjectType, json_loads_object
from .agent import AbstractConversationAgent, ConversationInput, ConversationResult
@ -696,14 +695,14 @@ class DefaultAgent(AbstractConversationAgent):
@core.callback
def _async_handle_area_registry_changed(
self, event: EventType[ar.EventAreaRegistryUpdatedData]
self, event: core.Event[ar.EventAreaRegistryUpdatedData]
) -> None:
"""Clear area area cache when the area registry has changed."""
self._slot_lists = None
@core.callback
def _async_handle_entity_registry_changed(
self, event: EventType[er.EventEntityRegistryUpdatedData]
self, event: core.Event[er.EventEntityRegistryUpdatedData]
) -> None:
"""Clear names list cache when an entity registry entry has changed."""
if event.data["action"] != "update" or not any(

View file

@ -31,7 +31,7 @@ from homeassistant.helpers.event import (
async_track_time_interval,
)
from homeassistant.helpers.httpx_client import get_async_client
from homeassistant.helpers.typing import UNDEFINED, ConfigType, EventType, UndefinedType
from homeassistant.helpers.typing import UNDEFINED, ConfigType, UndefinedType
from .const import DOMAIN, IMAGE_TIMEOUT # noqa: F401
@ -342,7 +342,7 @@ async def async_get_still_stream(
event = asyncio.Event()
async def image_state_update(_event: EventType[EventStateChangedData]) -> None:
async def image_state_update(_event: Event[EventStateChangedData]) -> None:
"""Write image to stream."""
event.set()

View file

@ -60,7 +60,6 @@ from homeassistant.helpers.typing import (
UNDEFINED,
ConfigType,
DiscoveryInfoType,
EventType,
UndefinedType,
)
from homeassistant.util.json import json_loads
@ -769,7 +768,7 @@ async def async_remove_discovery_payload(
async def async_clear_discovery_topic_if_entity_removed(
hass: HomeAssistant,
discovery_data: DiscoveryInfoType,
event: EventType[er.EventEntityRegistryUpdatedData],
event: Event[er.EventEntityRegistryUpdatedData],
) -> None:
"""Clear the discovery topic if the entity is removed."""
if event.data["action"] == "remove":

View file

@ -15,10 +15,10 @@ from homeassistant.const import (
CONF_ZONE,
UnitOfLength,
)
from homeassistant.core import HomeAssistant, State, callback
from homeassistant.core import Event, HomeAssistant, State, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType, EventType
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.util.location import distance
from homeassistant.util.unit_conversion import DistanceConverter
@ -107,7 +107,7 @@ class ProximityDataUpdateCoordinator(DataUpdateCoordinator[ProximityData]):
await self.async_refresh()
async def async_check_tracked_entity_change(
self, event: EventType[er.EventEntityRegistryUpdatedData]
self, event: Event[er.EventEntityRegistryUpdatedData]
) -> None:
"""Fetch and process tracked entity change event."""
data = event.data

View file

@ -9,10 +9,9 @@ import voluptuous as vol
from homeassistant.components.homeassistant import exposed_entities
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ENTITY_ID
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.event import async_track_entity_registry_updated_event
from homeassistant.helpers.typing import EventType
from .const import CONF_INVERT, CONF_TARGET_DOMAIN
from .light import LightSwitch
@ -58,7 +57,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return False
async def async_registry_updated(
event: EventType[er.EventEntityRegistryUpdatedData],
event: Event[er.EventEntityRegistryUpdatedData],
) -> None:
"""Handle entity registry update."""
data = event.data

View file

@ -68,7 +68,7 @@ from .event import (
async_track_device_registry_updated_event,
async_track_entity_registry_updated_event,
)
from .typing import UNDEFINED, EventType, StateType, UndefinedType
from .typing import UNDEFINED, StateType, UndefinedType
if TYPE_CHECKING:
from functools import cached_property
@ -1455,7 +1455,7 @@ class Entity(
@callback
def _async_registry_updated(
self, event: EventType[er.EventEntityRegistryUpdatedData]
self, event: Event[er.EventEntityRegistryUpdatedData]
) -> None:
"""Handle entity registry update."""
action = event.data["action"]
@ -1467,7 +1467,7 @@ class Entity(
)
async def _async_process_registry_update_or_remove(
self, event: EventType[er.EventEntityRegistryUpdatedData]
self, event: Event[er.EventEntityRegistryUpdatedData]
) -> None:
"""Handle entity registry update or remove."""
data = event.data

View file

@ -7,7 +7,7 @@ import dataclasses
from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal, TypedDict, cast
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.util import slugify
from .normalized_name_base_registry import (
@ -17,7 +17,7 @@ from .normalized_name_base_registry import (
)
from .registry import BaseRegistry
from .storage import Store
from .typing import UNDEFINED, EventType, UndefinedType
from .typing import UNDEFINED, UndefinedType
DATA_REGISTRY = "floor_registry"
EVENT_FLOOR_REGISTRY_UPDATED = "floor_registry_updated"
@ -32,7 +32,7 @@ class EventFloorRegistryUpdatedData(TypedDict):
floor_id: str
EventFloorRegistryUpdated = EventType[EventFloorRegistryUpdatedData]
EventFloorRegistryUpdated = Event[EventFloorRegistryUpdatedData]
@dataclass(slots=True, kw_only=True, frozen=True)

View file

@ -11,7 +11,7 @@ from types import ModuleType
from typing import Any
from homeassistant.const import EVENT_COMPONENT_LOADED
from homeassistant.core import HassJob, HomeAssistant, callback
from homeassistant.core import Event, HassJob, HomeAssistant, callback
from homeassistant.loader import (
Integration,
async_get_integrations,
@ -22,8 +22,6 @@ from homeassistant.loader import (
from homeassistant.setup import ATTR_COMPONENT, EventComponentLoaded
from homeassistant.util.logging import catch_log_exception
from .typing import EventType
_LOGGER = logging.getLogger(__name__)
DATA_INTEGRATION_PLATFORMS = "integration_platforms"
@ -41,7 +39,7 @@ class IntegrationPlatform:
def _async_integration_platform_component_loaded(
hass: HomeAssistant,
integration_platforms: list[IntegrationPlatform],
event: EventType[EventComponentLoaded],
event: Event[EventComponentLoaded],
) -> None:
"""Process integration platforms for a component."""
if "." in (component_name := event.data[ATTR_COMPONENT]):

View file

@ -7,7 +7,7 @@ import dataclasses
from dataclasses import dataclass
from typing import Literal, TypedDict, cast
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.util import slugify
from .normalized_name_base_registry import (
@ -17,7 +17,7 @@ from .normalized_name_base_registry import (
)
from .registry import BaseRegistry
from .storage import Store
from .typing import UNDEFINED, EventType, UndefinedType
from .typing import UNDEFINED, UndefinedType
DATA_REGISTRY = "label_registry"
EVENT_LABEL_REGISTRY_UPDATED = "label_registry_updated"
@ -32,7 +32,7 @@ class EventLabelRegistryUpdatedData(TypedDict):
label_id: str
EventLabelRegistryUpdated = EventType[EventLabelRegistryUpdatedData]
EventLabelRegistryUpdated = Event[EventLabelRegistryUpdatedData]
@dataclass(slots=True, frozen=True, kw_only=True)

View file

@ -28,7 +28,7 @@ from .core import (
from .exceptions import DependencyError, HomeAssistantError
from .helpers import translation
from .helpers.issue_registry import IssueSeverity, async_create_issue
from .helpers.typing import ConfigType, EventType
from .helpers.typing import ConfigType
from .util import ensure_unique_string
from .util.async_ import create_eager_task
@ -592,7 +592,7 @@ def _async_when_setup(
await when_setup()
@callback
def _async_is_component_filter(event: EventType[EventComponentLoaded]) -> bool:
def _async_is_component_filter(event: Event[EventComponentLoaded]) -> bool:
"""Check if the event is for the component."""
return event.data[ATTR_COMPONENT] == component

View file

@ -23,13 +23,12 @@ from homeassistant.const import (
STATE_ON,
STATE_UNAVAILABLE,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.event import (
EventStateChangedData,
async_track_state_change_event,
)
from homeassistant.helpers.typing import EventType
from .conftest import MockESPHomeDevice
@ -225,7 +224,7 @@ async def test_entities_removed_after_reload(
on_future = hass.loop.create_future()
@callback
def _async_wait_for_on(event: EventType[EventStateChangedData]) -> None:
def _async_wait_for_on(event: Event[EventStateChangedData]) -> None:
if event.data["new_state"].state == STATE_ON:
on_future.set_result(None)