diff --git a/homeassistant/components/websocket_api/__init__.py b/homeassistant/components/websocket_api/__init__.py index 1ec758ebd4d1a..2beb2aa278808 100644 --- a/homeassistant/components/websocket_api/__init__.py +++ b/homeassistant/components/websocket_api/__init__.py @@ -4,7 +4,6 @@ from . import commands, connection, const, decorators, http, messages - # mypy: allow-untyped-calls, allow-untyped-defs DOMAIN = const.DOMAIN diff --git a/homeassistant/components/websocket_api/auth.py b/homeassistant/components/websocket_api/auth.py index 3971d39ee73d3..9e33ed74fd406 100644 --- a/homeassistant/components/websocket_api/auth.py +++ b/homeassistant/components/websocket_api/auth.py @@ -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" diff --git a/homeassistant/components/websocket_api/commands.py b/homeassistant/components/websocket_api/commands.py index f30ee816914bd..93f926b537a80 100644 --- a/homeassistant/components/websocket_api/commands.py +++ b/homeassistant/components/websocket_api/commands.py @@ -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"] diff --git a/homeassistant/components/websocket_api/connection.py b/homeassistant/components/websocket_api/connection.py index 5a0284a34d4c1..ed24a70519d91 100644 --- a/homeassistant/components/websocket_api/connection.py +++ b/homeassistant/components/websocket_api/connection.py @@ -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 diff --git a/homeassistant/components/websocket_api/const.py b/homeassistant/components/websocket_api/const.py index fe9792c4ab3fc..8ad9443a4d643 100644 --- a/homeassistant/components/websocket_api/const.py +++ b/homeassistant/components/websocket_api/const.py @@ -3,6 +3,7 @@ from concurrent import futures from functools import partial import json + from homeassistant.helpers.json import JSONEncoder DOMAIN = "websocket_api" diff --git a/homeassistant/components/websocket_api/decorators.py b/homeassistant/components/websocket_api/decorators.py index 025131643e894..1a1330242bc0f 100644 --- a/homeassistant/components/websocket_api/decorators.py +++ b/homeassistant/components/websocket_api/decorators.py @@ -7,7 +7,6 @@ from . import messages - # mypy: allow-untyped-calls, allow-untyped-defs _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/websocket_api/http.py b/homeassistant/components/websocket_api/http.py index be1830aa07bdf..3921413fd28fe 100644 --- a/homeassistant/components/websocket_api/http.py +++ b/homeassistant/components/websocket_api/http.py @@ -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 diff --git a/homeassistant/components/websocket_api/messages.py b/homeassistant/components/websocket_api/messages.py index c8c760a654956..27d557e8110d3 100644 --- a/homeassistant/components/websocket_api/messages.py +++ b/homeassistant/components/websocket_api/messages.py @@ -6,7 +6,6 @@ from . import const - # mypy: allow-untyped-defs # Minimal requirements of a message diff --git a/homeassistant/components/websocket_api/permissions.py b/homeassistant/components/websocket_api/permissions.py index ffbb80fa19ec7..c270c0f0cccfc 100644 --- a/homeassistant/components/websocket_api/permissions.py +++ b/homeassistant/components/websocket_api/permissions.py @@ -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. diff --git a/homeassistant/components/websocket_api/sensor.py b/homeassistant/components/websocket_api/sensor.py index f8f1257aefca4..4ae39787335ad 100644 --- a/homeassistant/components/websocket_api/sensor.py +++ b/homeassistant/components/websocket_api/sensor.py @@ -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