Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve websocket_api schema typing #120411

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions homeassistant/components/websocket_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

from typing import Final, cast

import voluptuous as vol

from homeassistant.core import HomeAssistant, callback
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 . import commands, connection, const, decorators, http, messages # noqa: F401
Expand Down Expand Up @@ -55,7 +53,7 @@ def async_register_command(
hass: HomeAssistant,
command_or_handler: str | const.WebSocketCommandHandler,
handler: const.WebSocketCommandHandler | None = None,
schema: vol.Schema | None = None,
schema: VolSchemaType | None = None,
) -> None:
"""Register a websocket command."""
if handler is None:
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/websocket_api/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from homeassistant.const import HASSIO_USER_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import Unauthorized
from homeassistant.helpers.typing import VolDictType

from . import const, messages
from .connection import ActiveConnection
Expand Down Expand Up @@ -130,7 +131,7 @@ def output_error(message_id: str, message: str) -> None:


def websocket_command(
schema: dict[vol.Marker, Any] | vol.All,
schema: VolDictType | vol.All,
) -> Callable[[const.WebSocketCommandHandler], const.WebSocketCommandHandler]:
"""Tag a function as a websocket command.

Expand Down