Move imports to top for websocket_api (#29556)
* Move imports to top for websocket_api * Move back an import because of circular dependency, add annotationspull/29638/head
parent
21cf6777bb
commit
6de8072e8a
|
@ -4,7 +4,6 @@ from homeassistant.loader import bind_hass
|
|||
|
||||
from . import commands, connection, const, decorators, http, messages
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
|
||||
DOMAIN = const.DOMAIN
|
||||
|
|
|
@ -3,13 +3,12 @@ import voluptuous as vol
|
|||
from voluptuous.humanize import humanize_error
|
||||
|
||||
from homeassistant.auth.models import RefreshToken, User
|
||||
from homeassistant.components.http.ban import process_wrong_login, process_success_login
|
||||
from homeassistant.components.http.ban import process_success_login, process_wrong_login
|
||||
from homeassistant.const import __version__
|
||||
|
||||
from .connection import ActiveConnection
|
||||
from .error import Disconnect
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
|
||||
TYPE_AUTH = "auth"
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.auth.permissions.const import POLICY_READ
|
||||
from homeassistant.const import MATCH_ALL, EVENT_TIME_CHANGED, EVENT_STATE_CHANGED
|
||||
from homeassistant.core import callback, DOMAIN as HASS_DOMAIN
|
||||
from homeassistant.exceptions import Unauthorized, ServiceNotFound, HomeAssistantError
|
||||
from homeassistant.const import EVENT_STATE_CHANGED, EVENT_TIME_CHANGED, MATCH_ALL
|
||||
from homeassistant.core import DOMAIN as HASS_DOMAIN, callback
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceNotFound, Unauthorized
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.service import async_get_all_descriptions
|
||||
from homeassistant.helpers.event import async_track_state_change
|
||||
from homeassistant.helpers.service import async_get_all_descriptions
|
||||
|
||||
from . import const, decorators, messages
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
|
||||
|
||||
|
@ -45,6 +44,8 @@ def handle_subscribe_events(hass, connection, msg):
|
|||
|
||||
Async friendly.
|
||||
"""
|
||||
# Circular dep
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .permissions import SUBSCRIBE_WHITELIST
|
||||
|
||||
event_type = msg["event_type"]
|
||||
|
|
|
@ -4,12 +4,11 @@ from typing import Any, Callable, Dict, Hashable
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback, Context
|
||||
from homeassistant.core import Context, callback
|
||||
from homeassistant.exceptions import Unauthorized
|
||||
|
||||
from . import const, messages
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import asyncio
|
|||
from concurrent import futures
|
||||
from functools import partial
|
||||
import json
|
||||
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
|
||||
DOMAIN = "websocket_api"
|
||||
|
|
|
@ -7,7 +7,6 @@ from homeassistant.exceptions import Unauthorized
|
|||
|
||||
from . import messages
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -4,28 +4,27 @@ from contextlib import suppress
|
|||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from aiohttp import web, WSMsgType
|
||||
from aiohttp import WSMsgType, web
|
||||
import async_timeout
|
||||
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
|
||||
from .auth import AuthPhase, auth_required_message
|
||||
from .const import (
|
||||
MAX_PENDING_MSG,
|
||||
CANCELLATION_ERRORS,
|
||||
URL,
|
||||
DATA_CONNECTIONS,
|
||||
ERR_UNKNOWN_ERROR,
|
||||
JSON_DUMP,
|
||||
MAX_PENDING_MSG,
|
||||
SIGNAL_WEBSOCKET_CONNECTED,
|
||||
SIGNAL_WEBSOCKET_DISCONNECTED,
|
||||
DATA_CONNECTIONS,
|
||||
JSON_DUMP,
|
||||
URL,
|
||||
)
|
||||
from .auth import AuthPhase, auth_required_message
|
||||
from .error import Disconnect
|
||||
from .messages import error_message
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ from homeassistant.helpers import config_validation as cv
|
|||
|
||||
from . import const
|
||||
|
||||
|
||||
# mypy: allow-untyped-defs
|
||||
|
||||
# Minimal requirements of a message
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
Separate file to avoid circular imports.
|
||||
"""
|
||||
from homeassistant.components.frontend import EVENT_PANELS_UPDATED
|
||||
from homeassistant.components.lovelace import EVENT_LOVELACE_UPDATED
|
||||
from homeassistant.components.persistent_notification import (
|
||||
EVENT_PERSISTENT_NOTIFICATIONS_UPDATED,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
EVENT_COMPONENT_LOADED,
|
||||
EVENT_CORE_CONFIG_UPDATE,
|
||||
EVENT_SERVICE_REGISTERED,
|
||||
EVENT_SERVICE_REMOVED,
|
||||
EVENT_STATE_CHANGED,
|
||||
EVENT_THEMES_UPDATED,
|
||||
EVENT_CORE_CONFIG_UPDATE,
|
||||
)
|
||||
from homeassistant.components.persistent_notification import (
|
||||
EVENT_PERSISTENT_NOTIFICATIONS_UPDATED,
|
||||
)
|
||||
from homeassistant.components.lovelace import EVENT_LOVELACE_UPDATED
|
||||
from homeassistant.helpers.area_registry import EVENT_AREA_REGISTRY_UPDATED
|
||||
from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED
|
||||
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
|
||||
from homeassistant.components.frontend import EVENT_PANELS_UPDATED
|
||||
|
||||
# These are events that do not contain any sensitive data
|
||||
# Except for state_changed, which is handled accordingly.
|
||||
|
|
|
@ -4,12 +4,11 @@ from homeassistant.core import callback
|
|||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from .const import (
|
||||
DATA_CONNECTIONS,
|
||||
SIGNAL_WEBSOCKET_CONNECTED,
|
||||
SIGNAL_WEBSOCKET_DISCONNECTED,
|
||||
DATA_CONNECTIONS,
|
||||
)
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue