Move imports in yweather (#27842)

Changes checked with pylint.
Formatted with black
Imports sorted with isort
This commit is contained in:
Tomasz Jagusz 2019-10-18 10:11:53 +02:00 committed by cgtobi
parent 511766cb06
commit 675c91b436
2 changed files with 17 additions and 14 deletions

View file

@ -1,17 +1,23 @@
"""Support for the Yahoo! Weather service."""
import logging
from datetime import timedelta
import logging
import voluptuous as vol
from yahooweather import ( # pylint: disable=import-error
UNIT_C,
UNIT_F,
YahooWeather,
get_woeid,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
TEMP_CELSIUS,
ATTR_ATTRIBUTION,
CONF_MONITORED_CONDITIONS,
CONF_NAME,
ATTR_ATTRIBUTION,
TEMP_CELSIUS,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
@ -20,6 +26,7 @@ _LOGGER = logging.getLogger(__name__)
ATTRIBUTION = "Weather details provided by Yahoo! Inc."
CONF_FORECAST = "forecast"
CONF_WOEID = "woeid"
DEFAULT_NAME = "Yweather"
@ -52,8 +59,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Yahoo! weather sensor."""
from yahooweather import get_woeid, UNIT_C, UNIT_F
unit = hass.config.units.temperature_unit
woeid = config.get(CONF_WOEID)
forecast = config.get(CONF_FORECAST)
@ -181,8 +186,6 @@ class YahooWeatherData:
def __init__(self, woeid, temp_unit):
"""Initialize the data object."""
from yahooweather import YahooWeather
self._yahoo = YahooWeather(woeid, temp_unit)
@property

View file

@ -3,6 +3,12 @@ from datetime import timedelta
import logging
import voluptuous as vol
from yahooweather import ( # pylint: disable=import-error
UNIT_C,
UNIT_F,
YahooWeather,
get_woeid,
)
from homeassistant.components.weather import (
ATTR_FORECAST_CONDITION,
@ -21,7 +27,6 @@ DATA_CONDITION = "yahoo_condition"
ATTRIBUTION = "Weather details provided by Yahoo! Inc."
CONF_WOEID = "woeid"
DEFAULT_NAME = "Yweather"
@ -46,7 +51,6 @@ CONDITION_CLASSES = {
"exceptional": [0, 1, 2, 19, 22],
}
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_WOEID): cv.string,
@ -57,8 +61,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Yahoo! weather platform."""
from yahooweather import get_woeid, UNIT_C, UNIT_F
unit = hass.config.units.temperature_unit
woeid = config.get(CONF_WOEID)
name = config.get(CONF_NAME)
@ -181,8 +183,6 @@ class YahooWeatherData:
def __init__(self, woeid, temp_unit):
"""Initialize the data object."""
from yahooweather import YahooWeather
self._yahoo = YahooWeather(woeid, temp_unit)
@property