mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use covariant for fire event data type (#110843)
This commit is contained in:
parent
66a31407f9
commit
1c55ba0cb2
@ -262,7 +262,7 @@ class ImageProcessingFaceEntity(ImageProcessingEntity):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
face.update({ATTR_ENTITY_ID: self.entity_id})
|
face.update({ATTR_ENTITY_ID: self.entity_id})
|
||||||
self.hass.bus.async_fire(EVENT_DETECT_FACE, face) # type: ignore[arg-type]
|
self.hass.bus.async_fire(EVENT_DETECT_FACE, face)
|
||||||
|
|
||||||
# Update entity store
|
# Update entity store
|
||||||
self.faces = faces
|
self.faces = faces
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Event parser and human readable log generator."""
|
"""Event parser and human readable log generator."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable, Mapping
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.sensor import ATTR_STATE_CLASS
|
from homeassistant.components.sensor import ATTR_STATE_CLASS
|
||||||
@ -96,7 +96,7 @@ def async_determine_event_types(
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def extract_attr(source: dict[str, Any], attr: str) -> list[str]:
|
def extract_attr(source: Mapping[str, Any], attr: str) -> list[str]:
|
||||||
"""Extract an attribute as a list or string."""
|
"""Extract an attribute as a list or string."""
|
||||||
if (value := source.get(attr)) is None:
|
if (value := source.get(attr)) is None:
|
||||||
return []
|
return []
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Event parser and human readable log generator."""
|
"""Event parser and human readable log generator."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable, Mapping
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import TYPE_CHECKING, Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class LazyEventPartialState:
|
|||||||
class EventAsRow:
|
class EventAsRow:
|
||||||
"""Convert an event to a row."""
|
"""Convert an event to a row."""
|
||||||
|
|
||||||
data: dict[str, Any]
|
data: Mapping[str, Any]
|
||||||
context: Context
|
context: Context
|
||||||
context_id_bin: bytes
|
context_id_bin: bytes
|
||||||
time_fired_ts: float
|
time_fired_ts: float
|
||||||
|
@ -30,7 +30,7 @@ def async_describe_events(
|
|||||||
device: dr.DeviceEntry | None = None
|
device: dr.DeviceEntry | None = None
|
||||||
device_name: str = "Unknown device"
|
device_name: str = "Unknown device"
|
||||||
zha_device: ZHADevice | None = None
|
zha_device: ZHADevice | None = None
|
||||||
event_data: dict = event.data
|
event_data = event.data
|
||||||
event_type: str | None = None
|
event_type: str | None = None
|
||||||
event_subtype: str | None = None
|
event_subtype: str | None = None
|
||||||
|
|
||||||
|
@ -1067,7 +1067,7 @@ class Event:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
event_type: str,
|
event_type: str,
|
||||||
data: dict[str, Any] | None = None,
|
data: Mapping[str, Any] | None = None,
|
||||||
origin: EventOrigin = EventOrigin.local,
|
origin: EventOrigin = EventOrigin.local,
|
||||||
time_fired: datetime.datetime | None = None,
|
time_fired: datetime.datetime | None = None,
|
||||||
context: Context | None = None,
|
context: Context | None = None,
|
||||||
@ -1204,7 +1204,7 @@ class EventBus:
|
|||||||
def fire(
|
def fire(
|
||||||
self,
|
self,
|
||||||
event_type: str,
|
event_type: str,
|
||||||
event_data: dict[str, Any] | None = None,
|
event_data: Mapping[str, Any] | None = None,
|
||||||
origin: EventOrigin = EventOrigin.local,
|
origin: EventOrigin = EventOrigin.local,
|
||||||
context: Context | None = None,
|
context: Context | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1217,7 +1217,7 @@ class EventBus:
|
|||||||
def async_fire(
|
def async_fire(
|
||||||
self,
|
self,
|
||||||
event_type: str,
|
event_type: str,
|
||||||
event_data: dict[str, Any] | None = None,
|
event_data: Mapping[str, Any] | None = None,
|
||||||
origin: EventOrigin = EventOrigin.local,
|
origin: EventOrigin = EventOrigin.local,
|
||||||
context: Context | None = None,
|
context: Context | None = None,
|
||||||
time_fired: datetime.datetime | None = None,
|
time_fired: datetime.datetime | None = None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user