mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Replace EventType annotations with Event (#96426)
This commit is contained in:
parent
4bf23fac6f
commit
9e67bccb89
@ -35,7 +35,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import CoreState, Event, HomeAssistant, callback
|
from homeassistant.core import CoreState, Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import EventType, StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -457,7 +457,7 @@ async def async_setup_entry(
|
|||||||
if transport:
|
if transport:
|
||||||
# Register listener to close transport on HA shutdown
|
# Register listener to close transport on HA shutdown
|
||||||
@callback
|
@callback
|
||||||
def close_transport(_event: EventType) -> None:
|
def close_transport(_event: Event) -> None:
|
||||||
"""Close the transport on HA shutdown."""
|
"""Close the transport on HA shutdown."""
|
||||||
if not transport: # noqa: B023
|
if not transport: # noqa: B023
|
||||||
return
|
return
|
||||||
|
@ -44,11 +44,11 @@ from homeassistant.const import (
|
|||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, State, callback
|
from homeassistant.core import Event, HomeAssistant, State, callback
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_state_change_event
|
from homeassistant.helpers.event import async_track_state_change_event
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, EventType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
KEY_ANNOUNCE = "announce"
|
KEY_ANNOUNCE = "announce"
|
||||||
KEY_CLEAR_PLAYLIST = "clear_playlist"
|
KEY_CLEAR_PLAYLIST = "clear_playlist"
|
||||||
@ -130,7 +130,7 @@ class MediaPlayerGroup(MediaPlayerEntity):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_on_state_change(self, event: EventType) -> None:
|
def async_on_state_change(self, event: Event) -> None:
|
||||||
"""Update supported features and state when a new state is received."""
|
"""Update supported features and state when a new state is received."""
|
||||||
self.async_set_context(event.context)
|
self.async_set_context(event.context)
|
||||||
self.async_update_supported_features(
|
self.async_update_supported_features(
|
||||||
|
@ -30,7 +30,6 @@ from homeassistant.helpers.reload import async_setup_reload_service
|
|||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import (
|
||||||
ConfigType,
|
ConfigType,
|
||||||
DiscoveryInfoType,
|
DiscoveryInfoType,
|
||||||
EventType,
|
|
||||||
StateType,
|
StateType,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -287,7 +286,7 @@ class MinMaxSensor(SensorEntity):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_min_max_sensor_state_listener(
|
def _async_min_max_sensor_state_listener(
|
||||||
self, event: EventType, update_state: bool = True
|
self, event: Event, update_state: bool = True
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Handle the sensor state changes."""
|
"""Handle the sensor state changes."""
|
||||||
new_state: State | None = event.data.get("new_state")
|
new_state: State | None = event.data.get("new_state")
|
||||||
|
@ -5,8 +5,7 @@ from collections.abc import Callable
|
|||||||
|
|
||||||
from homeassistant.components.logbook import LOGBOOK_ENTRY_MESSAGE, LOGBOOK_ENTRY_NAME
|
from homeassistant.components.logbook import LOGBOOK_ENTRY_MESSAGE, LOGBOOK_ENTRY_NAME
|
||||||
from homeassistant.const import ATTR_DEVICE_ID
|
from homeassistant.const import ATTR_DEVICE_ID
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers.typing import EventType
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_CHANNEL,
|
ATTR_CHANNEL,
|
||||||
@ -27,12 +26,12 @@ from .utils import get_rpc_entity_name
|
|||||||
@callback
|
@callback
|
||||||
def async_describe_events(
|
def async_describe_events(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
async_describe_event: Callable[[str, str, Callable[[EventType], dict]], None],
|
async_describe_event: Callable[[str, str, Callable[[Event], dict]], None],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Describe logbook events."""
|
"""Describe logbook events."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_describe_shelly_click_event(event: EventType) -> dict[str, str]:
|
def async_describe_shelly_click_event(event: Event) -> dict[str, str]:
|
||||||
"""Describe shelly.click logbook event (block device)."""
|
"""Describe shelly.click logbook event (block device)."""
|
||||||
device_id = event.data[ATTR_DEVICE_ID]
|
device_id = event.data[ATTR_DEVICE_ID]
|
||||||
click_type = event.data[ATTR_CLICK_TYPE]
|
click_type = event.data[ATTR_CLICK_TYPE]
|
||||||
|
@ -12,7 +12,7 @@ from aioshelly.rpc_device import RpcDevice, WsServer
|
|||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers import singleton
|
from homeassistant.helpers import singleton
|
||||||
from homeassistant.helpers.device_registry import (
|
from homeassistant.helpers.device_registry import (
|
||||||
CONNECTION_NETWORK_MAC,
|
CONNECTION_NETWORK_MAC,
|
||||||
@ -20,7 +20,6 @@ from homeassistant.helpers.device_registry import (
|
|||||||
format_mac,
|
format_mac,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity_registry import async_get as er_async_get
|
from homeassistant.helpers.entity_registry import async_get as er_async_get
|
||||||
from homeassistant.helpers.typing import EventType
|
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -211,7 +210,7 @@ async def get_coap_context(hass: HomeAssistant) -> COAP:
|
|||||||
await context.initialize(port)
|
await context.initialize(port)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def shutdown_listener(ev: EventType) -> None:
|
def shutdown_listener(ev: Event) -> None:
|
||||||
context.close()
|
context.close()
|
||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, shutdown_listener)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, shutdown_listener)
|
||||||
|
@ -9,7 +9,6 @@ GPSType = tuple[float, float]
|
|||||||
ConfigType = dict[str, Any]
|
ConfigType = dict[str, Any]
|
||||||
ContextType = homeassistant.core.Context
|
ContextType = homeassistant.core.Context
|
||||||
DiscoveryInfoType = dict[str, Any]
|
DiscoveryInfoType = dict[str, Any]
|
||||||
EventType = homeassistant.core.Event
|
|
||||||
ServiceDataType = dict[str, Any]
|
ServiceDataType = dict[str, Any]
|
||||||
StateType = str | int | float | None
|
StateType = str | int | float | None
|
||||||
TemplateVarsType = Mapping[str, Any] | None
|
TemplateVarsType = Mapping[str, Any] | None
|
||||||
@ -33,4 +32,5 @@ UNDEFINED = UndefinedType._singleton # pylint: disable=protected-access
|
|||||||
# that may rely on them.
|
# that may rely on them.
|
||||||
# In due time they will be removed.
|
# In due time they will be removed.
|
||||||
HomeAssistantType = homeassistant.core.HomeAssistant
|
HomeAssistantType = homeassistant.core.HomeAssistant
|
||||||
|
EventType = homeassistant.core.Event
|
||||||
ServiceCallType = homeassistant.core.ServiceCall
|
ServiceCallType = homeassistant.core.ServiceCall
|
||||||
|
Loading…
x
Reference in New Issue
Block a user