From ed5cdb528c3c2a810843ec2fbc5a983b46676094 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Thu, 5 Dec 2019 13:44:11 +0100 Subject: [PATCH] Move imports to top for group (#29485) * Move imports to top for group * Fix failing test for group --- homeassistant/components/group/__init__.py | 21 +++++++------- homeassistant/components/group/cover.py | 24 ++++++++-------- homeassistant/components/group/light.py | 28 +++++++++---------- homeassistant/components/group/notify.py | 6 ++-- .../components/group/reproduce_state.py | 5 ++-- .../components/group/test_reproduce_state.py | 4 ++- 6 files changed, 42 insertions(+), 46 deletions(-) diff --git a/homeassistant/components/group/__init__.py b/homeassistant/components/group/__init__.py index ba12e22b53e..16094ed4832 100644 --- a/homeassistant/components/group/__init__.py +++ b/homeassistant/components/group/__init__.py @@ -7,34 +7,33 @@ import voluptuous as vol from homeassistant import core as ha from homeassistant.const import ( + ATTR_ASSUMED_STATE, ATTR_ENTITY_ID, + ATTR_ICON, + ATTR_NAME, CONF_ICON, CONF_NAME, + SERVICE_RELOAD, STATE_CLOSED, STATE_HOME, + STATE_LOCKED, STATE_NOT_HOME, STATE_OFF, + STATE_OK, STATE_ON, STATE_OPEN, - STATE_LOCKED, - STATE_UNLOCKED, - STATE_OK, STATE_PROBLEM, STATE_UNKNOWN, - ATTR_ASSUMED_STATE, - SERVICE_RELOAD, - ATTR_NAME, - ATTR_ICON, + STATE_UNLOCKED, ) from homeassistant.core import callback -from homeassistant.loader import bind_hass +import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.config_validation import make_entity_service_schema from homeassistant.helpers.entity import Entity, async_generate_entity_id from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.event import async_track_state_change -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.config_validation import make_entity_service_schema from homeassistant.helpers.typing import HomeAssistantType - +from homeassistant.loader import bind_hass # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs diff --git a/homeassistant/components/group/cover.py b/homeassistant/components/group/cover.py index f7a9643e5c8..d9efdfa53c6 100644 --- a/homeassistant/components/group/cover.py +++ b/homeassistant/components/group/cover.py @@ -4,18 +4,6 @@ from typing import Dict, Optional, Set import voluptuous as vol -from homeassistant.const import ( - ATTR_ASSUMED_STATE, - ATTR_ENTITY_ID, - ATTR_SUPPORTED_FEATURES, - CONF_ENTITIES, - CONF_NAME, - STATE_CLOSED, -) -from homeassistant.core import callback, State -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.event import async_track_state_change - from homeassistant.components.cover import ( ATTR_CURRENT_POSITION, ATTR_CURRENT_TILT_POSITION, @@ -41,7 +29,17 @@ from homeassistant.components.cover import ( SUPPORT_STOP_TILT, CoverDevice, ) - +from homeassistant.const import ( + ATTR_ASSUMED_STATE, + ATTR_ENTITY_ID, + ATTR_SUPPORTED_FEATURES, + CONF_ENTITIES, + CONF_NAME, + STATE_CLOSED, +) +from homeassistant.core import State, callback +import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.event import async_track_state_change # mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs # mypy: no-check-untyped-defs diff --git a/homeassistant/components/group/light.py b/homeassistant/components/group/light.py index 2cd65028131..f0c81696469 100644 --- a/homeassistant/components/group/light.py +++ b/homeassistant/components/group/light.py @@ -8,20 +8,6 @@ from typing import Any, Callable, Iterator, List, Optional, Tuple, cast import voluptuous as vol from homeassistant.components import light -from homeassistant.const import ( - ATTR_ENTITY_ID, - ATTR_SUPPORTED_FEATURES, - CONF_ENTITIES, - CONF_NAME, - STATE_ON, - STATE_UNAVAILABLE, -) -from homeassistant.core import CALLBACK_TYPE, State, callback -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.event import async_track_state_change -from homeassistant.helpers.typing import ConfigType, HomeAssistantType -from homeassistant.util import color as color_util - from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, @@ -42,7 +28,19 @@ from homeassistant.components.light import ( SUPPORT_TRANSITION, SUPPORT_WHITE_VALUE, ) - +from homeassistant.const import ( + ATTR_ENTITY_ID, + ATTR_SUPPORTED_FEATURES, + CONF_ENTITIES, + CONF_NAME, + STATE_ON, + STATE_UNAVAILABLE, +) +from homeassistant.core import CALLBACK_TYPE, State, callback +import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.event import async_track_state_change +from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.util import color as color_util # mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs # mypy: no-check-untyped-defs diff --git a/homeassistant/components/group/notify.py b/homeassistant/components/group/notify.py index e17990690fa..2209e0e2333 100644 --- a/homeassistant/components/group/notify.py +++ b/homeassistant/components/group/notify.py @@ -6,9 +6,6 @@ import logging import voluptuous as vol -from homeassistant.const import ATTR_SERVICE -import homeassistant.helpers.config_validation as cv - from homeassistant.components.notify import ( ATTR_DATA, ATTR_MESSAGE, @@ -16,7 +13,8 @@ from homeassistant.components.notify import ( PLATFORM_SCHEMA, BaseNotificationService, ) - +from homeassistant.const import ATTR_SERVICE +import homeassistant.helpers.config_validation as cv # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs diff --git a/homeassistant/components/group/reproduce_state.py b/homeassistant/components/group/reproduce_state.py index 827e9bb1dcb..78790701934 100644 --- a/homeassistant/components/group/reproduce_state.py +++ b/homeassistant/components/group/reproduce_state.py @@ -2,15 +2,16 @@ from typing import Iterable, Optional from homeassistant.core import Context, State +from homeassistant.helpers.state import async_reproduce_state from homeassistant.helpers.typing import HomeAssistantType +from . import get_entity_ids + async def async_reproduce_states( hass: HomeAssistantType, states: Iterable[State], context: Optional[Context] = None ) -> None: """Reproduce component states.""" - from . import get_entity_ids - from homeassistant.helpers.state import async_reproduce_state states_copy = [] for state in states: diff --git a/tests/components/group/test_reproduce_state.py b/tests/components/group/test_reproduce_state.py index 502ea9e51fc..f3a56a46472 100644 --- a/tests/components/group/test_reproduce_state.py +++ b/tests/components/group/test_reproduce_state.py @@ -21,7 +21,9 @@ async def test_reproduce_group(hass): context=state.context, ) - with patch("homeassistant.helpers.state.async_reproduce_state") as fun: + with patch( + "homeassistant.components.group.reproduce_state.async_reproduce_state" + ) as fun: fun.return_value = Future() fun.return_value.set_result(None)