Replace EventType annotations with Event (#96426)
This commit is contained in:
parent
4bf23fac6f
commit
9e67bccb89
6 changed files with 12 additions and 15 deletions
|
@ -35,7 +35,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import CoreState, Event, HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
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 .const import (
|
||||
|
@ -457,7 +457,7 @@ async def async_setup_entry(
|
|||
if transport:
|
||||
# Register listener to close transport on HA shutdown
|
||||
@callback
|
||||
def close_transport(_event: EventType) -> None:
|
||||
def close_transport(_event: Event) -> None:
|
||||
"""Close the transport on HA shutdown."""
|
||||
if not transport: # noqa: B023
|
||||
return
|
||||
|
|
|
@ -44,11 +44,11 @@ from homeassistant.const import (
|
|||
STATE_UNAVAILABLE,
|
||||
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.entity_platform import AddEntitiesCallback
|
||||
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_CLEAR_PLAYLIST = "clear_playlist"
|
||||
|
@ -130,7 +130,7 @@ class MediaPlayerGroup(MediaPlayerEntity):
|
|||
}
|
||||
|
||||
@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."""
|
||||
self.async_set_context(event.context)
|
||||
self.async_update_supported_features(
|
||||
|
|
|
@ -30,7 +30,6 @@ from homeassistant.helpers.reload import async_setup_reload_service
|
|||
from homeassistant.helpers.typing import (
|
||||
ConfigType,
|
||||
DiscoveryInfoType,
|
||||
EventType,
|
||||
StateType,
|
||||
)
|
||||
|
||||
|
@ -287,7 +286,7 @@ class MinMaxSensor(SensorEntity):
|
|||
|
||||
@callback
|
||||
def _async_min_max_sensor_state_listener(
|
||||
self, event: EventType, update_state: bool = True
|
||||
self, event: Event, update_state: bool = True
|
||||
) -> None:
|
||||
"""Handle the sensor state changes."""
|
||||
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.const import ATTR_DEVICE_ID
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.typing import EventType
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
|
||||
from .const import (
|
||||
ATTR_CHANNEL,
|
||||
|
@ -27,12 +26,12 @@ from .utils import get_rpc_entity_name
|
|||
@callback
|
||||
def async_describe_events(
|
||||
hass: HomeAssistant,
|
||||
async_describe_event: Callable[[str, str, Callable[[EventType], dict]], None],
|
||||
async_describe_event: Callable[[str, str, Callable[[Event], dict]], None],
|
||||
) -> None:
|
||||
"""Describe logbook events."""
|
||||
|
||||
@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)."""
|
||||
device_id = event.data[ATTR_DEVICE_ID]
|
||||
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.config_entries import ConfigEntry
|
||||
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.device_registry import (
|
||||
CONNECTION_NETWORK_MAC,
|
||||
|
@ -20,7 +20,6 @@ from homeassistant.helpers.device_registry import (
|
|||
format_mac,
|
||||
)
|
||||
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 .const import (
|
||||
|
@ -211,7 +210,7 @@ async def get_coap_context(hass: HomeAssistant) -> COAP:
|
|||
await context.initialize(port)
|
||||
|
||||
@callback
|
||||
def shutdown_listener(ev: EventType) -> None:
|
||||
def shutdown_listener(ev: Event) -> None:
|
||||
context.close()
|
||||
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, shutdown_listener)
|
||||
|
|
|
@ -9,7 +9,6 @@ GPSType = tuple[float, float]
|
|||
ConfigType = dict[str, Any]
|
||||
ContextType = homeassistant.core.Context
|
||||
DiscoveryInfoType = dict[str, Any]
|
||||
EventType = homeassistant.core.Event
|
||||
ServiceDataType = dict[str, Any]
|
||||
StateType = str | int | float | None
|
||||
TemplateVarsType = Mapping[str, Any] | None
|
||||
|
@ -33,4 +32,5 @@ UNDEFINED = UndefinedType._singleton # pylint: disable=protected-access
|
|||
# that may rely on them.
|
||||
# In due time they will be removed.
|
||||
HomeAssistantType = homeassistant.core.HomeAssistant
|
||||
EventType = homeassistant.core.Event
|
||||
ServiceCallType = homeassistant.core.ServiceCall
|
||||
|
|
Loading…
Add table
Reference in a new issue