use isort to sort imports according to PEP8 for automation (#29620)

This commit is contained in:
Bas Nijholt 2019-12-08 17:29:39 +01:00 committed by Fabian Affolter
parent a38f3ac9c6
commit d3f67c3841
30 changed files with 87 additions and 90 deletions

View file

@ -27,13 +27,12 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import make_entity_service_schema from homeassistant.helpers.config_validation import make_entity_service_schema
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import TemplateVarsType from homeassistant.helpers.typing import TemplateVarsType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
from homeassistant.util.dt import parse_datetime, utcnow from homeassistant.util.dt import parse_datetime, utcnow
# mypy: allow-untyped-calls, allow-untyped-defs # mypy: allow-untyped-calls, allow-untyped-defs
# mypy: no-check-untyped-defs, no-warn-return-any # mypy: no-check-untyped-defs, no-warn-return-any

View file

@ -7,8 +7,8 @@ import voluptuous as vol
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
from homeassistant.const import CONF_PLATFORM
from homeassistant.config import async_log_exception, config_without_domain from homeassistant.config import async_log_exception, config_without_domain
from homeassistant.const import CONF_PLATFORM
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import condition, config_per_platform, script from homeassistant.helpers import condition, config_per_platform, script
from homeassistant.loader import IntegrationNotFound from homeassistant.loader import IntegrationNotFound

View file

@ -7,7 +7,6 @@ from homeassistant.components.device_automation import (
) )
from homeassistant.const import CONF_DOMAIN from homeassistant.const import CONF_DOMAIN
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
TRIGGER_SCHEMA = TRIGGER_BASE_SCHEMA.extend({}, extra=vol.ALLOW_EXTRA) TRIGGER_SCHEMA = TRIGGER_BASE_SCHEMA.extend({}, extra=vol.ALLOW_EXTRA)

View file

@ -3,11 +3,10 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_PLATFORM from homeassistant.const import CONF_PLATFORM
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
# mypy: allow-untyped-defs # mypy: allow-untyped-defs
CONF_EVENT_TYPE = "event_type" CONF_EVENT_TYPE = "event_type"

View file

@ -2,7 +2,6 @@
import voluptuous as vol import voluptuous as vol
from homeassistant.components.geo_location import DOMAIN from homeassistant.components.geo_location import DOMAIN
from homeassistant.core import callback
from homeassistant.const import ( from homeassistant.const import (
CONF_EVENT, CONF_EVENT,
CONF_PLATFORM, CONF_PLATFORM,
@ -10,10 +9,10 @@ from homeassistant.const import (
CONF_ZONE, CONF_ZONE,
EVENT_STATE_CHANGED, EVENT_STATE_CHANGED,
) )
from homeassistant.core import callback
from homeassistant.helpers import condition, config_validation as cv from homeassistant.helpers import condition, config_validation as cv
from homeassistant.helpers.config_validation import entity_domain from homeassistant.helpers.config_validation import entity_domain
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
EVENT_ENTER = "enter" EVENT_ENTER = "enter"

View file

@ -3,9 +3,8 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback, CoreState from homeassistant.const import CONF_EVENT, CONF_PLATFORM, EVENT_HOMEASSISTANT_STOP
from homeassistant.const import CONF_PLATFORM, CONF_EVENT, EVENT_HOMEASSISTANT_STOP from homeassistant.core import CoreState, callback
# mypy: allow-untyped-defs # mypy: allow-untyped-defs

View file

@ -3,12 +3,11 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_PLATFORM from homeassistant.const import CONF_PLATFORM
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
import homeassistant.util.dt as dt_util
from homeassistant.helpers.event import track_point_in_utc_time from homeassistant.helpers.event import track_point_in_utc_time
import homeassistant.util.dt as dt_util
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs

View file

@ -3,12 +3,11 @@ import json
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.const import CONF_PLATFORM, CONF_PAYLOAD from homeassistant.const import CONF_PAYLOAD, CONF_PLATFORM
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
# mypy: allow-untyped-defs # mypy: allow-untyped-defs
CONF_ENCODING = "encoding" CONF_ENCODING = "encoding"

View file

@ -4,18 +4,17 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant import exceptions from homeassistant import exceptions
from homeassistant.core import CALLBACK_TYPE, callback
from homeassistant.const import ( from homeassistant.const import (
CONF_VALUE_TEMPLATE,
CONF_PLATFORM,
CONF_ENTITY_ID,
CONF_BELOW,
CONF_ABOVE, CONF_ABOVE,
CONF_BELOW,
CONF_ENTITY_ID,
CONF_FOR, CONF_FOR,
CONF_PLATFORM,
CONF_VALUE_TEMPLATE,
) )
from homeassistant.helpers.event import async_track_state_change, async_track_same_state from homeassistant.core import CALLBACK_TYPE, callback
from homeassistant.helpers import condition, config_validation as cv, template from homeassistant.helpers import condition, config_validation as cv, template
from homeassistant.helpers.event import async_track_same_state, async_track_state_change
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs # mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
# mypy: no-check-untyped-defs # mypy: no-check-untyped-defs

View file

@ -5,10 +5,10 @@ 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

View file

@ -6,11 +6,10 @@ from typing import Dict
import voluptuous as vol import voluptuous as vol
from homeassistant import exceptions from homeassistant import exceptions
from homeassistant.core import HomeAssistant, CALLBACK_TYPE, callback from homeassistant.const import CONF_FOR, CONF_PLATFORM, MATCH_ALL
from homeassistant.const import MATCH_ALL, CONF_PLATFORM, CONF_FOR from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, template from homeassistant.helpers import config_validation as cv, template
from homeassistant.helpers.event import async_track_state_change, async_track_same_state from homeassistant.helpers.event import async_track_same_state, async_track_state_change
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs # mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
# mypy: no-check-untyped-defs # mypy: no-check-untyped-defs

View file

@ -4,16 +4,15 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import ( from homeassistant.const import (
CONF_EVENT, CONF_EVENT,
CONF_OFFSET, CONF_OFFSET,
CONF_PLATFORM, CONF_PLATFORM,
SUN_EVENT_SUNRISE, SUN_EVENT_SUNRISE,
) )
from homeassistant.helpers.event import async_track_sunrise, async_track_sunset from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_sunrise, async_track_sunset
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs

View file

@ -3,13 +3,11 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_VALUE_TEMPLATE, CONF_PLATFORM, CONF_FOR
from homeassistant import exceptions from homeassistant import exceptions
from homeassistant.helpers import condition from homeassistant.const import CONF_FOR, CONF_PLATFORM, CONF_VALUE_TEMPLATE
from homeassistant.core import callback
from homeassistant.helpers import condition, config_validation as cv, template
from homeassistant.helpers.event import async_track_same_state, async_track_template from homeassistant.helpers.event import async_track_same_state, async_track_template
from homeassistant.helpers import config_validation as cv, template
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs

View file

@ -3,12 +3,11 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_AT, CONF_PLATFORM from homeassistant.const import CONF_AT, CONF_PLATFORM
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.event import async_track_time_change from homeassistant.helpers.event import async_track_time_change
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -3,12 +3,11 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_PLATFORM from homeassistant.const import CONF_PLATFORM
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.event import async_track_time_change from homeassistant.helpers.event import async_track_time_change
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
CONF_HOURS = "hours" CONF_HOURS = "hours"

View file

@ -5,13 +5,12 @@ import logging
from aiohttp import hdrs from aiohttp import hdrs
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_PLATFORM, CONF_WEBHOOK_ID from homeassistant.const import CONF_PLATFORM, CONF_WEBHOOK_ID
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from . import DOMAIN as AUTOMATION_DOMAIN from . import DOMAIN as AUTOMATION_DOMAIN
# mypy: allow-untyped-defs # mypy: allow-untyped-defs
DEPENDENCIES = ("webhook",) DEPENDENCIES = ("webhook",)

View file

@ -1,17 +1,16 @@
"""Offer zone automation rules.""" """Offer zone automation rules."""
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import ( from homeassistant.const import (
CONF_EVENT,
CONF_ENTITY_ID, CONF_ENTITY_ID,
CONF_EVENT,
CONF_PLATFORM,
CONF_ZONE, CONF_ZONE,
MATCH_ALL, MATCH_ALL,
CONF_PLATFORM,
) )
from homeassistant.helpers.event import async_track_state_change from homeassistant.core import callback
from homeassistant.helpers import condition, config_validation as cv, location from homeassistant.helpers import condition, config_validation as cv, location
from homeassistant.helpers.event import async_track_state_change
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs

View file

@ -6,11 +6,11 @@ components. Instead call the service directly.
from homeassistant.components.automation import DOMAIN, SERVICE_TRIGGER from homeassistant.components.automation import DOMAIN, SERVICE_TRIGGER
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
SERVICE_TURN_ON,
SERVICE_TURN_OFF,
SERVICE_TOGGLE,
SERVICE_RELOAD,
ENTITY_MATCH_ALL, ENTITY_MATCH_ALL,
SERVICE_RELOAD,
SERVICE_TOGGLE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
) )
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass

View file

@ -1,13 +1,12 @@
"""The tests for the Event automation.""" """The tests for the Event automation."""
import pytest import pytest
import homeassistant.components.automation as automation
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.components.automation as automation
from tests.common import mock_component from tests.common import async_mock_service, mock_component
from tests.components.automation import common from tests.components.automation import common
from tests.common import async_mock_service
@pytest.fixture @pytest.fixture

View file

@ -5,9 +5,8 @@ from homeassistant.components import automation, zone
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.common import mock_component from tests.common import async_mock_service, mock_component
from tests.components.automation import common from tests.components.automation import common
from tests.common import async_mock_service
@pytest.fixture @pytest.fixture

View file

@ -1,9 +1,9 @@
"""The tests for the Event automation.""" """The tests for the Event automation."""
from unittest.mock import patch, Mock from unittest.mock import Mock, patch
import homeassistant.components.automation as automation
from homeassistant.core import CoreState from homeassistant.core import CoreState
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.components.automation as automation
from tests.common import async_mock_service, mock_coro from tests.common import async_mock_service, mock_coro

View file

@ -1,13 +1,14 @@
"""The tests for the litejet component.""" """The tests for the litejet component."""
from datetime import timedelta
import logging import logging
from unittest import mock from unittest import mock
from datetime import timedelta
import pytest import pytest
from homeassistant import setup from homeassistant import setup
import homeassistant.util.dt as dt_util
from homeassistant.components import litejet from homeassistant.components import litejet
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
import homeassistant.util.dt as dt_util
from tests.common import async_fire_time_changed, async_mock_service from tests.common import async_fire_time_changed, async_mock_service

View file

@ -1,14 +1,16 @@
"""The tests for the MQTT automation.""" """The tests for the MQTT automation."""
import pytest
from unittest import mock from unittest import mock
from homeassistant.setup import async_setup_component import pytest
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.setup import async_setup_component
from tests.common import ( from tests.common import (
async_fire_mqtt_message, async_fire_mqtt_message,
mock_component,
async_mock_service,
async_mock_mqtt_component, async_mock_mqtt_component,
async_mock_service,
mock_component,
) )
from tests.components.automation import common from tests.components.automation import common

View file

@ -1,18 +1,19 @@
"""The tests for numeric state automation.""" """The tests for numeric state automation."""
from datetime import timedelta from datetime import timedelta
import pytest
from unittest.mock import patch from unittest.mock import patch
import pytest
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.setup import async_setup_component 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 (
mock_component,
async_fire_time_changed,
assert_setup_component, assert_setup_component,
async_fire_time_changed,
async_mock_service, async_mock_service,
mock_component,
) )
from tests.components.automation import common from tests.components.automation import common

View file

@ -1,17 +1,21 @@
"""The test for state automation.""" """The test for state automation."""
from datetime import timedelta from datetime import timedelta
import pytest
from unittest.mock import patch from unittest.mock import patch
import pytest
import homeassistant.components.automation as automation
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
import homeassistant.components.automation as automation
from tests.common import async_fire_time_changed, assert_setup_component, mock_component from tests.common import (
assert_setup_component,
async_fire_time_changed,
async_mock_service,
mock_component,
)
from tests.components.automation import common from tests.components.automation import common
from tests.common import async_mock_service
@pytest.fixture @pytest.fixture

View file

@ -1,16 +1,16 @@
"""The tests for the sun automation.""" """The tests for the sun automation."""
from datetime import datetime from datetime import datetime
import pytest
from unittest.mock import patch from unittest.mock import patch
from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET import pytest
from homeassistant.setup import async_setup_component
from homeassistant.components import sun from homeassistant.components import sun
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
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 async_fire_time_changed, mock_component, async_mock_service from tests.common import async_fire_time_changed, async_mock_service, mock_component
from tests.components.automation import common from tests.components.automation import common
ORIG_TIME_ZONE = dt_util.DEFAULT_TIME_ZONE ORIG_TIME_ZONE = dt_util.DEFAULT_TIME_ZONE

View file

@ -4,14 +4,18 @@ from unittest import mock
import pytest import pytest
import homeassistant.components.automation as automation
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
import homeassistant.components.automation as automation
from tests.common import async_fire_time_changed, assert_setup_component, mock_component from tests.common import (
assert_setup_component,
async_fire_time_changed,
async_mock_service,
mock_component,
)
from tests.components.automation import common from tests.components.automation import common
from tests.common import async_mock_service
@pytest.fixture @pytest.fixture

View file

@ -4,12 +4,16 @@ from unittest.mock import patch
import pytest import pytest
import homeassistant.components.automation as automation
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
import homeassistant.components.automation as automation
from tests.common import async_fire_time_changed, assert_setup_component, mock_component from tests.common import (
from tests.common import async_mock_service assert_setup_component,
async_fire_time_changed,
async_mock_service,
mock_component,
)
@pytest.fixture @pytest.fixture

View file

@ -1,13 +1,12 @@
"""The tests for the time_pattern automation.""" """The tests for the time_pattern automation."""
import pytest import pytest
import homeassistant.components.automation as automation
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
import homeassistant.components.automation as automation
from tests.common import async_fire_time_changed, mock_component from tests.common import async_fire_time_changed, async_mock_service, mock_component
from tests.components.automation import common from tests.components.automation import common
from tests.common import async_mock_service
@pytest.fixture @pytest.fixture

View file

@ -1,12 +1,12 @@
"""The tests for the location automation.""" """The tests for the location automation."""
import pytest import pytest
from homeassistant.components import automation, zone
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.components import automation, zone
from tests.components.automation import common
from tests.common import async_mock_service, mock_component from tests.common import async_mock_service, mock_component
from tests.components.automation import common
@pytest.fixture @pytest.fixture