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

Move imports to top for websocket_api #29556

Merged
merged 2 commits into from
Dec 8, 2019
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
1 change: 0 additions & 1 deletion homeassistant/components/websocket_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from . import commands, connection, const, decorators, http, messages


# mypy: allow-untyped-calls, allow-untyped-defs

DOMAIN = const.DOMAIN
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/websocket_api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
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"
Expand Down
11 changes: 6 additions & 5 deletions homeassistant/components/websocket_api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a reason this is here. It's for circular imports.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up! Moved it back in 6a1e5a6


event_type = msg["event_type"]
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/websocket_api/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

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


Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/websocket_api/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from concurrent import futures
from functools import partial
import json

from homeassistant.helpers.json import JSONEncoder

DOMAIN = "websocket_api"
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/websocket_api/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from . import messages


# mypy: allow-untyped-calls, allow-untyped-defs

_LOGGER = logging.getLogger(__name__)
Expand Down
15 changes: 7 additions & 8 deletions homeassistant/components/websocket_api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@
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


Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/websocket_api/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from . import const


# mypy: allow-untyped-defs

# Minimal requirements of a message
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/websocket_api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/websocket_api/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
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


Expand Down