diff --git a/homeassistant/components/bthome/logbook.py b/homeassistant/components/bthome/logbook.py index 475fa84fb76..23976e368ad 100644 --- a/homeassistant/components/bthome/logbook.py +++ b/homeassistant/components/bthome/logbook.py @@ -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"]) diff --git a/homeassistant/components/conversation/default_agent.py b/homeassistant/components/conversation/default_agent.py index 4d7ca4a47ee..4ca5c85676e 100644 --- a/homeassistant/components/conversation/default_agent.py +++ b/homeassistant/components/conversation/default_agent.py @@ -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( diff --git a/homeassistant/components/image/__init__.py b/homeassistant/components/image/__init__.py index 101a1cdf8c4..02ebee49701 100644 --- a/homeassistant/components/image/__init__.py +++ b/homeassistant/components/image/__init__.py @@ -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() diff --git a/homeassistant/components/mqtt/mixins.py b/homeassistant/components/mqtt/mixins.py index b6d83e2d420..84afe26bc97 100644 --- a/homeassistant/components/mqtt/mixins.py +++ b/homeassistant/components/mqtt/mixins.py @@ -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": diff --git a/homeassistant/components/proximity/coordinator.py b/homeassistant/components/proximity/coordinator.py index 047ab1b6b3a..d5f4a33d31e 100644 --- a/homeassistant/components/proximity/coordinator.py +++ b/homeassistant/components/proximity/coordinator.py @@ -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 diff --git a/homeassistant/components/switch_as_x/__init__.py b/homeassistant/components/switch_as_x/__init__.py index 23de494396e..71cb9e9c225 100644 --- a/homeassistant/components/switch_as_x/__init__.py +++ b/homeassistant/components/switch_as_x/__init__.py @@ -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 diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 6318cf8e13b..767b24a67a6 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -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 diff --git a/homeassistant/helpers/floor_registry.py b/homeassistant/helpers/floor_registry.py index a701cd5bf79..eba3a05cea8 100644 --- a/homeassistant/helpers/floor_registry.py +++ b/homeassistant/helpers/floor_registry.py @@ -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) diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index 54e4e0f9fb9..e142f9c2e5a 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -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]): diff --git a/homeassistant/helpers/label_registry.py b/homeassistant/helpers/label_registry.py index 666a573fe43..b3ca89140a1 100644 --- a/homeassistant/helpers/label_registry.py +++ b/homeassistant/helpers/label_registry.py @@ -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) diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 3ec72654a64..4b920bf364b 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -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 diff --git a/tests/components/esphome/test_entity.py b/tests/components/esphome/test_entity.py index 4056c286b51..303d50f3103 100644 --- a/tests/components/esphome/test_entity.py +++ b/tests/components/esphome/test_entity.py @@ -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)