Move imports to top for lyft (#29391)

This commit is contained in:
springstan 2019-12-04 11:14:35 +01:00 committed by Fabian Affolter
parent 025c1a39a7
commit c6fd8582a9

View File

@ -1,13 +1,16 @@
"""Support for the Lyft API.""" """Support for the Lyft API."""
import logging
from datetime import timedelta from datetime import timedelta
import logging
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.client import LyftRidesClient
from lyft_rides.errors import APIError
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -38,8 +41,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Lyft sensor.""" """Set up the Lyft sensor."""
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.errors import APIError
auth_flow = ClientCredentialGrant( auth_flow = ClientCredentialGrant(
client_id=config.get(CONF_CLIENT_ID), client_id=config.get(CONF_CLIENT_ID),
@ -208,7 +209,6 @@ class LyftEstimate:
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self): def update(self):
"""Get the latest product info and estimates from the Lyft API.""" """Get the latest product info and estimates from the Lyft API."""
from lyft_rides.errors import APIError
try: try:
self.fetch_data() self.fetch_data()
@ -217,7 +217,6 @@ class LyftEstimate:
def fetch_data(self): def fetch_data(self):
"""Get the latest product info and estimates from the Lyft API.""" """Get the latest product info and estimates from the Lyft API."""
from lyft_rides.client import LyftRidesClient
client = LyftRidesClient(self._session) client = LyftRidesClient(self._session)