From 1ee80576621933e3264e9c9fb8cbd12ba61e175c Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Fri, 6 Dec 2019 22:12:46 +0100 Subject: [PATCH] Move imports to top for zha (#29555) * Move imports to top for zha * Move back some imports, add annotation for disabling import-outside-toplevel * Move import config_flow before import api --- homeassistant/components/zha/__init__.py | 2 +- homeassistant/components/zha/core/channels/__init__.py | 2 +- homeassistant/components/zha/core/channels/hvac.py | 2 +- .../components/zha/core/channels/manufacturerspecific.py | 1 - homeassistant/components/zha/core/channels/security.py | 2 +- homeassistant/components/zha/core/device.py | 2 +- homeassistant/components/zha/core/store.py | 3 +-- homeassistant/components/zha/device_trigger.py | 2 +- 8 files changed, 7 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index ecd27c48839..07eb3c53a95 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -100,7 +100,7 @@ async def async_setup_entry(hass, config_entry): if config.get(CONF_ENABLE_QUIRKS, True): # needs to be done here so that the ZHA module is finished loading # before zhaquirks is imported - import zhaquirks # noqa: F401 pylint: disable=unused-import + import zhaquirks # noqa: F401 pylint: disable=unused-import, import-outside-toplevel zha_gateway = ZHAGateway(hass, config, config_entry) await zha_gateway.async_initialize() diff --git a/homeassistant/components/zha/core/channels/__init__.py b/homeassistant/components/zha/core/channels/__init__.py index 29cecb7784e..2d24c4ce045 100644 --- a/homeassistant/components/zha/core/channels/__init__.py +++ b/homeassistant/components/zha/core/channels/__init__.py @@ -394,7 +394,7 @@ class EventRelayChannel(ZigbeeChannel): ) -# pylint: disable=wrong-import-position +# pylint: disable=wrong-import-position, import-outside-toplevel from . import closures # noqa: F401 from . import general # noqa: F401 from . import homeautomation # noqa: F401 diff --git a/homeassistant/components/zha/core/channels/hvac.py b/homeassistant/components/zha/core/channels/hvac.py index 14d982ab1e8..db4745d51c3 100644 --- a/homeassistant/components/zha/core/channels/hvac.py +++ b/homeassistant/components/zha/core/channels/hvac.py @@ -6,6 +6,7 @@ https://home-assistant.io/integrations/zha/ """ import logging +from zigpy.exceptions import DeliveryError import zigpy.zcl.clusters.hvac as hvac from homeassistant.core import callback @@ -35,7 +36,6 @@ class FanChannel(ZigbeeChannel): async def async_set_speed(self, value) -> None: """Set the speed of the fan.""" - from zigpy.exceptions import DeliveryError try: await self.cluster.write_attributes({"fan_mode": value}) diff --git a/homeassistant/components/zha/core/channels/manufacturerspecific.py b/homeassistant/components/zha/core/channels/manufacturerspecific.py index 31dd5cd63d1..39f45f6c4a2 100644 --- a/homeassistant/components/zha/core/channels/manufacturerspecific.py +++ b/homeassistant/components/zha/core/channels/manufacturerspecific.py @@ -18,7 +18,6 @@ from ..const import ( SIGNAL_ATTR_UPDATED, ) - _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/zha/core/channels/security.py b/homeassistant/components/zha/core/channels/security.py index e4840dae86d..69e4ea1a27a 100644 --- a/homeassistant/components/zha/core/channels/security.py +++ b/homeassistant/components/zha/core/channels/security.py @@ -6,6 +6,7 @@ https://home-assistant.io/integrations/zha/ """ import logging +from zigpy.exceptions import DeliveryError import zigpy.zcl.clusters.security as security from homeassistant.core import callback @@ -149,7 +150,6 @@ class IASZoneChannel(ZigbeeChannel): if self._zha_device.manufacturer == "LUMI": self.debug("finished IASZoneChannel configuration") return - from zigpy.exceptions import DeliveryError self.debug("started IASZoneChannel configuration") diff --git a/homeassistant/components/zha/core/device.py b/homeassistant/components/zha/core/device.py index e5d1678ad6f..9ace477d621 100644 --- a/homeassistant/components/zha/core/device.py +++ b/homeassistant/components/zha/core/device.py @@ -11,8 +11,8 @@ import logging import time import zigpy.exceptions -import zigpy.quirks from zigpy.profiles import zha, zll +import zigpy.quirks from homeassistant.core import callback from homeassistant.helpers.dispatcher import ( diff --git a/homeassistant/components/zha/core/store.py b/homeassistant/components/zha/core/store.py index bcc9b2a42d4..46fef76b656 100644 --- a/homeassistant/components/zha/core/store.py +++ b/homeassistant/components/zha/core/store.py @@ -2,8 +2,7 @@ # pylint: disable=unused-import from collections import OrderedDict import logging -from typing import MutableMapping -from typing import cast +from typing import MutableMapping, cast import attr diff --git a/homeassistant/components/zha/device_trigger.py b/homeassistant/components/zha/device_trigger.py index cdd62b11d1e..b7c46e5a40a 100644 --- a/homeassistant/components/zha/device_trigger.py +++ b/homeassistant/components/zha/device_trigger.py @@ -2,11 +2,11 @@ import voluptuous as vol import homeassistant.components.automation.event as event +from homeassistant.components.device_automation import TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE -from homeassistant.components.device_automation import TRIGGER_BASE_SCHEMA from . import DOMAIN from .core.helpers import async_get_zha_device