Use global imports for ESPHome (#24158)

* Use global import for ESPHome

* Add aioesphomeapi to test requirements

aioesphomeapi is also shipped as a pure-python wheel, so this should not impact test install time
This commit is contained in:
Otto Winter 2019-05-29 13:33:49 +02:00 committed by Pascal Vizeli
parent d9c78b77cb
commit 015c8811a5
11 changed files with 69 additions and 118 deletions

View file

@ -1,6 +1,8 @@
"""Support for ESPHome covers."""
import logging
from typing import TYPE_CHECKING, Optional
from typing import Optional
from aioesphomeapi import CoverInfo, CoverState
from homeassistant.components.cover import (
ATTR_POSITION, ATTR_TILT_POSITION, SUPPORT_CLOSE, SUPPORT_CLOSE_TILT,
@ -9,11 +11,7 @@ from homeassistant.components.cover import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType
from . import EsphomeEntity, platform_async_setup_entry, esphome_state_property
if TYPE_CHECKING:
# pylint: disable=unused-import
from aioesphomeapi import CoverInfo, CoverState # noqa
from . import EsphomeEntity, esphome_state_property, platform_async_setup_entry
_LOGGER = logging.getLogger(__name__)
@ -21,9 +19,6 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass: HomeAssistantType,
entry: ConfigEntry, async_add_entities) -> None:
"""Set up ESPHome covers based on a config entry."""
# pylint: disable=redefined-outer-name
from aioesphomeapi import CoverInfo, CoverState # noqa
await platform_async_setup_entry(
hass, entry, async_add_entities,
component_key='cover',
@ -36,7 +31,7 @@ class EsphomeCover(EsphomeEntity, CoverDevice):
"""A cover implementation for ESPHome."""
@property
def _static_info(self) -> 'CoverInfo':
def _static_info(self) -> CoverInfo:
return super()._static_info
@property
@ -61,7 +56,7 @@ class EsphomeCover(EsphomeEntity, CoverDevice):
return self._static_info.assumed_state
@property
def _state(self) -> Optional['CoverState']:
def _state(self) -> Optional[CoverState]:
return super()._state
@esphome_state_property