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
This commit is contained in:
springstan 2019-12-06 22:12:46 +01:00 committed by Alexei Chetroi
parent fb66a6cf81
commit 1ee8057662
8 changed files with 7 additions and 9 deletions

View File

@ -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()

View File

@ -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

View File

@ -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})

View File

@ -18,7 +18,6 @@ from ..const import (
SIGNAL_ATTR_UPDATED,
)
_LOGGER = logging.getLogger(__name__)

View File

@ -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")

View File

@ -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 (

View File

@ -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

View File

@ -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