use isort to sort imports according to PEP8 for light (#29648)

This commit is contained in:
Bas Nijholt 2019-12-08 18:16:23 +01:00 committed by Fabian Affolter
parent ce5072fc91
commit aeff27680b
15 changed files with 86 additions and 85 deletions

View file

@ -17,7 +17,7 @@ from homeassistant.const import (
SERVICE_TURN_ON, SERVICE_TURN_ON,
STATE_ON, STATE_ON,
) )
from homeassistant.exceptions import UnknownUser, Unauthorized from homeassistant.exceptions import Unauthorized, UnknownUser
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa: F401 from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
@ -29,7 +29,6 @@ from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
DOMAIN = "light" DOMAIN = "light"

View file

@ -1,13 +1,14 @@
"""Provides device actions for lights.""" """Provides device actions for lights."""
from typing import List from typing import List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant, Context
from homeassistant.components.device_automation import toggle_entity from homeassistant.components.device_automation import toggle_entity
from homeassistant.const import CONF_DOMAIN from homeassistant.const import CONF_DOMAIN
from homeassistant.helpers.typing import TemplateVarsType, ConfigType from homeassistant.core import Context, HomeAssistant
from . import DOMAIN from homeassistant.helpers.typing import ConfigType, TemplateVarsType
from . import DOMAIN
ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN}) ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN})

View file

@ -1,14 +1,15 @@
"""Provides device conditions for lights.""" """Provides device conditions for lights."""
from typing import Dict, List from typing import Dict, List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant
from homeassistant.components.device_automation import toggle_entity from homeassistant.components.device_automation import toggle_entity
from homeassistant.const import CONF_DOMAIN from homeassistant.const import CONF_DOMAIN
from homeassistant.helpers.typing import ConfigType from homeassistant.core import HomeAssistant
from homeassistant.helpers.condition import ConditionCheckerType from homeassistant.helpers.condition import ConditionCheckerType
from . import DOMAIN from homeassistant.helpers.typing import ConfigType
from . import DOMAIN
CONDITION_SCHEMA = toggle_entity.CONDITION_SCHEMA.extend( CONDITION_SCHEMA = toggle_entity.CONDITION_SCHEMA.extend(
{vol.Required(CONF_DOMAIN): DOMAIN} {vol.Required(CONF_DOMAIN): DOMAIN}

View file

@ -1,14 +1,15 @@
"""Provides device trigger for lights.""" """Provides device trigger for lights."""
from typing import List from typing import List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant, CALLBACK_TYPE
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
from homeassistant.components.device_automation import toggle_entity from homeassistant.components.device_automation import toggle_entity
from homeassistant.const import CONF_DOMAIN from homeassistant.const import CONF_DOMAIN
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from . import DOMAIN
from . import DOMAIN
TRIGGER_SCHEMA = toggle_entity.TRIGGER_SCHEMA.extend( TRIGGER_SCHEMA = toggle_entity.TRIGGER_SCHEMA.extend(
{vol.Required(CONF_DOMAIN): DOMAIN} {vol.Required(CONF_DOMAIN): DOMAIN}

View file

@ -3,20 +3,19 @@ import voluptuous as vol
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import intent from homeassistant.helpers import intent
import homeassistant.util.color as color_util
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util
from . import ( from . import (
ATTR_ENTITY_ID,
SUPPORT_COLOR,
ATTR_RGB_COLOR,
ATTR_BRIGHTNESS_PCT, ATTR_BRIGHTNESS_PCT,
SUPPORT_BRIGHTNESS, ATTR_ENTITY_ID,
ATTR_RGB_COLOR,
DOMAIN, DOMAIN,
SERVICE_TURN_ON, SERVICE_TURN_ON,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
) )
INTENT_SET = "HassLightSet" INTENT_SET = "HassLightSet"

View file

@ -6,16 +6,15 @@ from typing import Iterable, Optional
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
STATE_ON,
STATE_OFF,
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
SERVICE_TURN_ON, SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
) )
from homeassistant.core import Context, State from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
from . import ( from . import (
DOMAIN,
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
ATTR_BRIGHTNESS_PCT, ATTR_BRIGHTNESS_PCT,
ATTR_COLOR_NAME, ATTR_COLOR_NAME,
@ -29,6 +28,7 @@ from . import (
ATTR_TRANSITION, ATTR_TRANSITION,
ATTR_WHITE_VALUE, ATTR_WHITE_VALUE,
ATTR_XY_COLOR, ATTR_XY_COLOR,
DOMAIN,
) )
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -15,7 +15,8 @@ from homeassistant.components.mqtt.discovery import (
clear_discovery_hash, clear_discovery_hash,
) )
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.typing import HomeAssistantType, ConfigType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from .schema import CONF_SCHEMA, MQTT_LIGHT_SCHEMA_SCHEMA from .schema import CONF_SCHEMA, MQTT_LIGHT_SCHEMA_SCHEMA
from .schema_basic import PLATFORM_SCHEMA_BASIC, async_setup_entity_basic from .schema_basic import PLATFORM_SCHEMA_BASIC, async_setup_entity_basic
from .schema_json import PLATFORM_SCHEMA_JSON, async_setup_entity_json from .schema_json import PLATFORM_SCHEMA_JSON, async_setup_entity_json

View file

@ -8,7 +8,6 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.components import mqtt from homeassistant.components import mqtt
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
@ -16,29 +15,12 @@ from homeassistant.components.light import (
ATTR_EFFECT, ATTR_EFFECT,
ATTR_HS_COLOR, ATTR_HS_COLOR,
ATTR_WHITE_VALUE, ATTR_WHITE_VALUE,
Light,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_COLOR,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
) Light,
from homeassistant.const import (
CONF_BRIGHTNESS,
CONF_COLOR_TEMP,
CONF_DEVICE,
CONF_EFFECT,
CONF_HS,
CONF_NAME,
CONF_OPTIMISTIC,
CONF_PAYLOAD_OFF,
CONF_PAYLOAD_ON,
STATE_ON,
CONF_RGB,
CONF_STATE,
CONF_VALUE_TEMPLATE,
CONF_WHITE_VALUE,
CONF_XY,
) )
from homeassistant.components.mqtt import ( from homeassistant.components.mqtt import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -52,8 +34,26 @@ from homeassistant.components.mqtt import (
MqttEntityDeviceInfo, MqttEntityDeviceInfo,
subscription, subscription,
) )
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import (
CONF_BRIGHTNESS,
CONF_COLOR_TEMP,
CONF_DEVICE,
CONF_EFFECT,
CONF_HS,
CONF_NAME,
CONF_OPTIMISTIC,
CONF_PAYLOAD_OFF,
CONF_PAYLOAD_ON,
CONF_RGB,
CONF_STATE,
CONF_VALUE_TEMPLATE,
CONF_WHITE_VALUE,
CONF_XY,
STATE_ON,
)
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from .schema import MQTT_LIGHT_SCHEMA_SCHEMA from .schema import MQTT_LIGHT_SCHEMA_SCHEMA

View file

@ -5,9 +5,9 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.mqtt_template/ https://home-assistant.io/components/light.mqtt_template/
""" """
import logging import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.components import mqtt from homeassistant.components import mqtt
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
@ -17,21 +17,14 @@ from homeassistant.components.light import (
ATTR_HS_COLOR, ATTR_HS_COLOR,
ATTR_TRANSITION, ATTR_TRANSITION,
ATTR_WHITE_VALUE, ATTR_WHITE_VALUE,
Light,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_COLOR,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
) Light,
from homeassistant.const import (
CONF_DEVICE,
CONF_NAME,
CONF_OPTIMISTIC,
STATE_ON,
STATE_OFF,
) )
from homeassistant.components.mqtt import ( from homeassistant.components.mqtt import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -45,9 +38,17 @@ from homeassistant.components.mqtt import (
MqttEntityDeviceInfo, MqttEntityDeviceInfo,
subscription, subscription,
) )
from homeassistant.const import (
CONF_DEVICE,
CONF_NAME,
CONF_OPTIMISTIC,
STATE_OFF,
STATE_ON,
)
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.util.color as color_util
from .schema import MQTT_LIGHT_SCHEMA_SCHEMA from .schema import MQTT_LIGHT_SCHEMA_SCHEMA

View file

@ -21,10 +21,10 @@ from homeassistant.components.light import (
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
ENTITY_MATCH_ALL,
SERVICE_TOGGLE, SERVICE_TOGGLE,
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
SERVICE_TURN_ON, SERVICE_TURN_ON,
ENTITY_MATCH_ALL,
) )
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass

View file

@ -1,18 +1,18 @@
"""The test for light device automation.""" """The test for light device automation."""
import pytest import pytest
from homeassistant.components.light import DOMAIN
from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM
from homeassistant.setup import async_setup_component
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.components.light import DOMAIN
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
from homeassistant.helpers import device_registry from homeassistant.helpers import device_registry
from homeassistant.setup import async_setup_component
from tests.common import ( from tests.common import (
MockConfigEntry, MockConfigEntry,
async_get_device_automations,
async_mock_service, async_mock_service,
mock_device_registry, mock_device_registry,
mock_registry, mock_registry,
async_get_device_automations,
) )

View file

@ -1,22 +1,23 @@
"""The test for light device automation.""" """The test for light device automation."""
from datetime import timedelta from datetime import timedelta
import pytest
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.light import DOMAIN import pytest
from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM
from homeassistant.setup import async_setup_component
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.components.light import DOMAIN
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
from homeassistant.helpers import device_registry from homeassistant.helpers import device_registry
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.common import ( from tests.common import (
MockConfigEntry, MockConfigEntry,
async_get_device_automation_capabilities,
async_get_device_automations,
async_mock_service, async_mock_service,
mock_device_registry, mock_device_registry,
mock_registry, mock_registry,
async_get_device_automations,
async_get_device_automation_capabilities,
) )

View file

@ -1,22 +1,23 @@
"""The test for light device automation.""" """The test for light device automation."""
from datetime import timedelta from datetime import timedelta
import pytest import pytest
from homeassistant.components.light import DOMAIN
from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM
from homeassistant.setup import async_setup_component
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.components.light import DOMAIN
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
from homeassistant.helpers import device_registry from homeassistant.helpers import device_registry
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.common import ( from tests.common import (
MockConfigEntry, MockConfigEntry,
async_fire_time_changed, async_fire_time_changed,
async_get_device_automation_capabilities,
async_get_device_automations,
async_mock_service, async_mock_service,
mock_device_registry, mock_device_registry,
mock_registry, mock_registry,
async_get_device_automations,
async_get_device_automation_capabilities,
) )

View file

@ -1,31 +1,27 @@
"""The tests for the Light component.""" """The tests for the Light component."""
# pylint: disable=protected-access # pylint: disable=protected-access
from io import StringIO
import os
import unittest import unittest
import unittest.mock as mock import unittest.mock as mock
import os
from io import StringIO
import pytest import pytest
from homeassistant import core from homeassistant import core
from homeassistant.exceptions import Unauthorized from homeassistant.components import light
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
STATE_ON,
STATE_OFF,
CONF_PLATFORM, CONF_PLATFORM,
SERVICE_TURN_ON,
SERVICE_TURN_OFF,
SERVICE_TOGGLE, SERVICE_TOGGLE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
) )
from homeassistant.components import light from homeassistant.exceptions import Unauthorized
from homeassistant.setup import async_setup_component, setup_component
from tests.common import ( from tests.common import get_test_home_assistant, mock_service, mock_storage
mock_service,
get_test_home_assistant,
mock_storage,
)
from tests.components.light import common from tests.components.light import common

View file

@ -1,9 +1,9 @@
"""Tests for the light intents.""" """Tests for the light intents."""
from homeassistant.helpers.intent import IntentHandleError
from homeassistant.const import ATTR_SUPPORTED_FEATURES, SERVICE_TURN_ON, ATTR_ENTITY_ID
from homeassistant.components import light from homeassistant.components import light
from homeassistant.components.light import intent from homeassistant.components.light import intent
from homeassistant.const import ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, SERVICE_TURN_ON
from homeassistant.helpers.intent import IntentHandleError
from tests.common import async_mock_service from tests.common import async_mock_service