mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
Rename callback type
This commit is contained in:
@@ -23,8 +23,8 @@ from homeassistant.helpers import config_validation as cv, device_registry as dr
|
|||||||
from homeassistant.helpers.automation import move_top_level_schema_fields_to_options
|
from homeassistant.helpers.automation import move_top_level_schema_fields_to_options
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.trigger import (
|
from homeassistant.helpers.trigger import (
|
||||||
RunTriggerActionCallback,
|
|
||||||
Trigger,
|
Trigger,
|
||||||
|
TriggerActionRunnerCallback,
|
||||||
TriggerConfig,
|
TriggerConfig,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
@@ -131,7 +131,7 @@ class EventTrigger(Trigger):
|
|||||||
_event_name: str
|
_event_name: str
|
||||||
_event_data_filter: dict
|
_event_data_filter: dict
|
||||||
_unsubs: list[Callable]
|
_unsubs: list[Callable]
|
||||||
_action_runner: RunTriggerActionCallback
|
_action_runner: TriggerActionRunnerCallback
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def async_validate_complete_config(
|
async def async_validate_complete_config(
|
||||||
@@ -175,7 +175,7 @@ class EventTrigger(Trigger):
|
|||||||
self._options = config.options
|
self._options = config.options
|
||||||
|
|
||||||
async def async_attach_runner(
|
async def async_attach_runner(
|
||||||
self, run_action: RunTriggerActionCallback
|
self, run_action: TriggerActionRunnerCallback
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
dev_reg = dr.async_get(self._hass)
|
dev_reg = dr.async_get(self._hass)
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ from homeassistant.helpers import config_validation as cv, device_registry as dr
|
|||||||
from homeassistant.helpers.automation import move_top_level_schema_fields_to_options
|
from homeassistant.helpers.automation import move_top_level_schema_fields_to_options
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.trigger import (
|
from homeassistant.helpers.trigger import (
|
||||||
RunTriggerActionCallback,
|
|
||||||
Trigger,
|
Trigger,
|
||||||
|
TriggerActionRunnerCallback,
|
||||||
TriggerConfig,
|
TriggerConfig,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
@@ -93,7 +93,7 @@ async def async_validate_trigger_config(
|
|||||||
|
|
||||||
|
|
||||||
async def async_attach_trigger(
|
async def async_attach_trigger(
|
||||||
hass: HomeAssistant, options: ConfigType, run_action: RunTriggerActionCallback
|
hass: HomeAssistant, options: ConfigType, run_action: TriggerActionRunnerCallback
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Listen for state changes based on configuration."""
|
"""Listen for state changes based on configuration."""
|
||||||
dev_reg = dr.async_get(hass)
|
dev_reg = dr.async_get(hass)
|
||||||
@@ -232,7 +232,7 @@ class ValueUpdatedTrigger(Trigger):
|
|||||||
self._options = config.options
|
self._options = config.options
|
||||||
|
|
||||||
async def async_attach_runner(
|
async def async_attach_runner(
|
||||||
self, run_action: RunTriggerActionCallback
|
self, run_action: TriggerActionRunnerCallback
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
return await async_attach_trigger(self._hass, self._options, run_action)
|
return await async_attach_trigger(self._hass, self._options, run_action)
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ class Trigger(abc.ABC):
|
|||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
async def async_attach_runner(
|
async def async_attach_runner(
|
||||||
self, run_action: RunTriggerActionCallback
|
self, run_action: TriggerActionRunnerCallback
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach the trigger to an action runner."""
|
"""Attach the trigger to an action runner."""
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ class TriggerConfig:
|
|||||||
options: dict[str, Any] | None = None
|
options: dict[str, Any] | None = None
|
||||||
|
|
||||||
|
|
||||||
class RunTriggerActionCallback(Protocol):
|
class TriggerActionRunnerCallback(Protocol):
|
||||||
"""Protocol type for the trigger action runner helper callback."""
|
"""Protocol type for the trigger action runner helper callback."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ from homeassistant.helpers.automation import move_top_level_schema_fields_to_opt
|
|||||||
from homeassistant.helpers.trigger import (
|
from homeassistant.helpers.trigger import (
|
||||||
DATA_PLUGGABLE_ACTIONS,
|
DATA_PLUGGABLE_ACTIONS,
|
||||||
PluggableAction,
|
PluggableAction,
|
||||||
RunTriggerActionCallback,
|
|
||||||
Trigger,
|
Trigger,
|
||||||
|
TriggerActionRunnerCallback,
|
||||||
_async_get_trigger_platform,
|
_async_get_trigger_platform,
|
||||||
async_initialize_triggers,
|
async_initialize_triggers,
|
||||||
async_validate_trigger_config,
|
async_validate_trigger_config,
|
||||||
@@ -464,7 +464,7 @@ async def test_platform_multiple_triggers(hass: HomeAssistant) -> None:
|
|||||||
"""Mock trigger 1."""
|
"""Mock trigger 1."""
|
||||||
|
|
||||||
async def async_attach_runner(
|
async def async_attach_runner(
|
||||||
self, run_action: RunTriggerActionCallback
|
self, run_action: TriggerActionRunnerCallback
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
run_action("trigger 1 desc", {"extra": "test_trigger_1"})
|
run_action("trigger 1 desc", {"extra": "test_trigger_1"})
|
||||||
@@ -473,7 +473,7 @@ async def test_platform_multiple_triggers(hass: HomeAssistant) -> None:
|
|||||||
"""Mock trigger 2."""
|
"""Mock trigger 2."""
|
||||||
|
|
||||||
async def async_attach_runner(
|
async def async_attach_runner(
|
||||||
self, run_action: RunTriggerActionCallback
|
self, run_action: TriggerActionRunnerCallback
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
run_action("trigger 2 desc", {"extra": "test_trigger_2"})
|
run_action("trigger 2 desc", {"extra": "test_trigger_2"})
|
||||||
|
|||||||
Reference in New Issue
Block a user