Improve MQTT Callable
type hints (#87838)
This commit is contained in:
parent
1a35c2d805
commit
71b67e20e4
3 changed files with 5 additions and 5 deletions
|
@ -134,7 +134,7 @@ class Trigger:
|
|||
|
||||
async def add_trigger(
|
||||
self, action: TriggerActionType, trigger_info: TriggerInfo
|
||||
) -> Callable:
|
||||
) -> Callable[[], None]:
|
||||
"""Add MQTT trigger."""
|
||||
instance = TriggerInstance(action, trigger_info, self)
|
||||
self.trigger_instances.append(instance)
|
||||
|
|
|
@ -37,6 +37,7 @@ from .const import (
|
|||
from .debug_info import log_messages
|
||||
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
|
||||
from .models import (
|
||||
MessageCallbackType,
|
||||
MqttCommandTemplate,
|
||||
MqttValueTemplate,
|
||||
PublishPayloadType,
|
||||
|
@ -173,7 +174,7 @@ class MqttTextEntity(MqttEntity, TextEntity):
|
|||
topics: dict[str, Any] = {}
|
||||
|
||||
def add_subscription(
|
||||
topics: dict[str, Any], topic: str, msg_callback: Callable
|
||||
topics: dict[str, Any], topic: str, msg_callback: MessageCallbackType
|
||||
) -> None:
|
||||
if self._config.get(topic) is not None:
|
||||
topics[topic] = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""Configure update platform in a device through MQTT topic."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
import functools
|
||||
import logging
|
||||
from typing import Any
|
||||
|
@ -35,7 +34,7 @@ from .const import (
|
|||
)
|
||||
from .debug_info import log_messages
|
||||
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
|
||||
from .models import MqttValueTemplate, ReceiveMessage
|
||||
from .models import MessageCallbackType, MqttValueTemplate, ReceiveMessage
|
||||
from .util import get_mqtt_data, valid_publish_topic, valid_subscribe_topic
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -148,7 +147,7 @@ class MqttUpdate(MqttEntity, UpdateEntity, RestoreEntity):
|
|||
topics: dict[str, Any] = {}
|
||||
|
||||
def add_subscription(
|
||||
topics: dict[str, Any], topic: str, msg_callback: Callable
|
||||
topics: dict[str, Any], topic: str, msg_callback: MessageCallbackType
|
||||
) -> None:
|
||||
if self._config.get(topic) is not None:
|
||||
topics[topic] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue