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): if config.get(CONF_ENABLE_QUIRKS, True):
# needs to be done here so that the ZHA module is finished loading # needs to be done here so that the ZHA module is finished loading
# before zhaquirks is imported # 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) zha_gateway = ZHAGateway(hass, config, config_entry)
await zha_gateway.async_initialize() 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 closures # noqa: F401
from . import general # noqa: F401 from . import general # noqa: F401
from . import homeautomation # noqa: F401 from . import homeautomation # noqa: F401

View File

@ -6,6 +6,7 @@ https://home-assistant.io/integrations/zha/
""" """
import logging import logging
from zigpy.exceptions import DeliveryError
import zigpy.zcl.clusters.hvac as hvac import zigpy.zcl.clusters.hvac as hvac
from homeassistant.core import callback from homeassistant.core import callback
@ -35,7 +36,6 @@ class FanChannel(ZigbeeChannel):
async def async_set_speed(self, value) -> None: async def async_set_speed(self, value) -> None:
"""Set the speed of the fan.""" """Set the speed of the fan."""
from zigpy.exceptions import DeliveryError
try: try:
await self.cluster.write_attributes({"fan_mode": value}) await self.cluster.write_attributes({"fan_mode": value})

View File

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

View File

@ -6,6 +6,7 @@ https://home-assistant.io/integrations/zha/
""" """
import logging import logging
from zigpy.exceptions import DeliveryError
import zigpy.zcl.clusters.security as security import zigpy.zcl.clusters.security as security
from homeassistant.core import callback from homeassistant.core import callback
@ -149,7 +150,6 @@ class IASZoneChannel(ZigbeeChannel):
if self._zha_device.manufacturer == "LUMI": if self._zha_device.manufacturer == "LUMI":
self.debug("finished IASZoneChannel configuration") self.debug("finished IASZoneChannel configuration")
return return
from zigpy.exceptions import DeliveryError
self.debug("started IASZoneChannel configuration") self.debug("started IASZoneChannel configuration")

View File

@ -11,8 +11,8 @@ import logging
import time import time
import zigpy.exceptions import zigpy.exceptions
import zigpy.quirks
from zigpy.profiles import zha, zll from zigpy.profiles import zha, zll
import zigpy.quirks
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (

View File

@ -2,8 +2,7 @@
# pylint: disable=unused-import # pylint: disable=unused-import
from collections import OrderedDict from collections import OrderedDict
import logging import logging
from typing import MutableMapping from typing import MutableMapping, cast
from typing import cast
import attr import attr

View File

@ -2,11 +2,11 @@
import voluptuous as vol import voluptuous as vol
import homeassistant.components.automation.event as event import homeassistant.components.automation.event as event
from homeassistant.components.device_automation import TRIGGER_BASE_SCHEMA
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE 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 . import DOMAIN
from .core.helpers import async_get_zha_device from .core.helpers import async_get_zha_device