mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Improve websocket_api schema typing (#120411)
This commit is contained in:
parent
b5afc5a7f0
commit
b816fce976
@ -4,11 +4,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Final, cast
|
from typing import Final, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType, VolSchemaType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
|
|
||||||
from . import commands, connection, const, decorators, http, messages # noqa: F401
|
from . import commands, connection, const, decorators, http, messages # noqa: F401
|
||||||
@ -55,7 +53,7 @@ def async_register_command(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
command_or_handler: str | const.WebSocketCommandHandler,
|
command_or_handler: str | const.WebSocketCommandHandler,
|
||||||
handler: const.WebSocketCommandHandler | None = None,
|
handler: const.WebSocketCommandHandler | None = None,
|
||||||
schema: vol.Schema | None = None,
|
schema: VolSchemaType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register a websocket command."""
|
"""Register a websocket command."""
|
||||||
if handler is None:
|
if handler is None:
|
||||||
|
@ -11,6 +11,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.const import HASSIO_USER_NAME
|
from homeassistant.const import HASSIO_USER_NAME
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import Unauthorized
|
from homeassistant.exceptions import Unauthorized
|
||||||
|
from homeassistant.helpers.typing import VolDictType
|
||||||
|
|
||||||
from . import const, messages
|
from . import const, messages
|
||||||
from .connection import ActiveConnection
|
from .connection import ActiveConnection
|
||||||
@ -130,7 +131,7 @@ def ws_require_user(
|
|||||||
|
|
||||||
|
|
||||||
def websocket_command(
|
def websocket_command(
|
||||||
schema: dict[vol.Marker, Any] | vol.All,
|
schema: VolDictType | vol.All,
|
||||||
) -> Callable[[const.WebSocketCommandHandler], const.WebSocketCommandHandler]:
|
) -> Callable[[const.WebSocketCommandHandler], const.WebSocketCommandHandler]:
|
||||||
"""Tag a function as a websocket command.
|
"""Tag a function as a websocket command.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user