Skip to content

Commit

Permalink
PyLint 1.5 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Nov 29, 2015
1 parent 01203c7 commit a301d86
Show file tree
Hide file tree
Showing 32 changed files with 87 additions and 85 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/automation/numeric_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _in_range(value, range_start, range_end):
try:
value = float(value)
except ValueError:
_LOGGER.warn("Missing value in numeric check")
_LOGGER.warning("Missing value in numeric check")
return False

if range_start is not None and range_end is not None:
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/automation/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def zone_automation_listener(entity, from_s, to_s):
from_match = _in_zone(hass, zone_entity_id, from_s) if from_s else None
to_match = _in_zone(hass, zone_entity_id, to_s)

# pylint: disable=too-many-boolean-expressions
if event == EVENT_ENTER and not from_match and to_match or \
event == EVENT_LEAVE and from_match and not to_match:
action()
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/binary_sensor/arest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.arest/
"""
from datetime import timedelta
import logging

import requests
from datetime import timedelta

from homeassistant.util import Throttle
from homeassistant.components.binary_sensor import BinarySensorDevice
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/camera/
"""
import requests
import logging
import time
import re
import time

import requests

from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.const import (
ATTR_ENTITY_PICTURE,
HTTP_NOT_FOUND,
ATTR_ENTITY_ID,
)

from homeassistant.helpers.entity_component import EntityComponent


DOMAIN = 'camera'
DEPENDENCIES = ['http']
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/camera/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
https://home-assistant.io/components/camera.generic/
"""
import logging

import requests
from requests.auth import HTTPBasicAuth

from homeassistant.helpers import validate_config
from homeassistant.components.camera import DOMAIN
from homeassistant.components.camera import Camera
import requests
from homeassistant.components.camera import DOMAIN, Camera

_LOGGER = logging.getLogger(__name__)

Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/camera/mjpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/camera.mjpeg/
"""
from contextlib import closing
import logging

import requests
from requests.auth import HTTPBasicAuth

from homeassistant.helpers import validate_config
from homeassistant.components.camera import DOMAIN
from homeassistant.components.camera import Camera
import requests
from contextlib import closing
from homeassistant.components.camera import DOMAIN, Camera

_LOGGER = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/ecobee.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
"""

from datetime import timedelta
import logging
import os

from homeassistant.loader import get_component
from homeassistant import bootstrap
from homeassistant.util import Throttle
from homeassistant.const import (
EVENT_PLATFORM_DISCOVERED, ATTR_SERVICE, ATTR_DISCOVERED, CONF_API_KEY)
from datetime import timedelta
import logging
import os

DOMAIN = "ecobee"
DISCOVER_THERMOSTAT = "ecobee.thermostat"
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/light/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.zwave/
"""
# Because we do not compile openzwave on CI
# pylint: disable=import-error
import homeassistant.components.zwave as zwave
from threading import Timer

from homeassistant.const import STATE_ON, STATE_OFF
from homeassistant.components.light import (Light, ATTR_BRIGHTNESS)
from threading import Timer
import homeassistant.components.zwave as zwave


def setup_platform(hass, config, add_devices, discovery_info=None):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/media_player/firetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_LOGGER.info(
'Device %s accessible and ready for control', device_id)
else:
_LOGGER.warn(
_LOGGER.warning(
'Device %s is not registered with firetv-server', device_id)
except requests.exceptions.RequestException:
_LOGGER.error('Could not connect to firetv-server at %s', host)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/notify/xmpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"""
import logging

_LOGGER = logging.getLogger(__name__)

from homeassistant.helpers import validate_config
from homeassistant.components.notify import (
DOMAIN, ATTR_TITLE, BaseNotificationService)

REQUIREMENTS = ['sleekxmpp==1.3.1', 'dnspython3==1.12.0']

_LOGGER = logging.getLogger(__name__)


def get_service(hass, config):
""" Get the Jabber (XMPP) notification service. """
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def row_to_state(row):
def row_to_event(row):
""" Convert a databse row to an event. """
try:
return Event(row[1], json.loads(row[2]), EventOrigin[row[3].lower()],
return Event(row[1], json.loads(row[2]), EventOrigin(row[3]),
date_util.utc_from_timestamp(row[5]))
except ValueError:
# When json.loads fails
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"""
import logging
from datetime import timedelta
import homeassistant.util.dt as date_util
from itertools import islice
import threading

from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.event import track_point_in_utc_time
from homeassistant.util import slugify, split_entity_id
import homeassistant.util.dt as date_util
from homeassistant.const import (
ATTR_ENTITY_ID, EVENT_TIME_CHANGED, STATE_ON, SERVICE_TURN_ON,
SERVICE_TURN_OFF)
Expand Down Expand Up @@ -73,12 +73,12 @@ def service_handler(service):

for object_id, cfg in config[DOMAIN].items():
if object_id != slugify(object_id):
_LOGGER.warn("Found invalid key for script: %s. Use %s instead.",
object_id, slugify(object_id))
_LOGGER.warning("Found invalid key for script: %s. Use %s instead",
object_id, slugify(object_id))
continue
if not isinstance(cfg.get(CONF_SEQUENCE), list):
_LOGGER.warn("Key 'sequence' for script %s should be a list",
object_id)
_LOGGER.warning("Key 'sequence' for script %s should be a list",
object_id)
continue
alias = cfg.get(CONF_ALIAS, object_id)
script = Script(hass, object_id, alias, cfg[CONF_SEQUENCE])
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/sensor/arest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.arest/
"""
from datetime import timedelta
import logging

import requests
from datetime import timedelta

from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
from homeassistant.const import DEVICE_DEFAULT_NAME
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle

_LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/sensor/ecobee.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
hold_temp: True
"""
import logging

from homeassistant.helpers.entity import Entity
from homeassistant.components import ecobee
from homeassistant.const import TEMP_FAHRENHEIT
import logging

DEPENDENCIES = ['ecobee']

Expand Down
16 changes: 4 additions & 12 deletions homeassistant/components/sensor/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@
import logging
from datetime import timedelta

REQUIREMENTS = ['python-forecastio==1.3.3']

try:
import forecastio
except ImportError:
forecastio = None

from homeassistant.util import Throttle
from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS)
from homeassistant.helpers.entity import Entity

REQUIREMENTS = ['python-forecastio==1.3.3']
_LOGGER = logging.getLogger(__name__)

# Sensor types are defined like so:
Expand Down Expand Up @@ -53,11 +47,7 @@

def setup_platform(hass, config, add_devices, discovery_info=None):
""" Get the Forecast.io sensor. """

global forecastio # pylint: disable=invalid-name
if forecastio is None:
import forecastio as forecastio_
forecastio = forecastio_
import forecastio

if None in (hass.config.latitude, hass.config.longitude):
_LOGGER.error("Latitude or longitude not set in Home Assistant config")
Expand Down Expand Up @@ -141,6 +131,7 @@ def unit_system(self):
# pylint: disable=too-many-branches
def update(self):
""" Gets the latest data from Forecast.io and updates the states. """
import forecastio

self.forecast_client.update()
data = self.forecast_client.data
Expand Down Expand Up @@ -209,6 +200,7 @@ def __init__(self, api_key, latitude, longitude, units):
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
""" Gets the latest data from Forecast.io. """
import forecastio

forecast = forecastio.load_forecast(self._api_key,
self.latitude,
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/sensor/glances.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.glances/
"""
from datetime import timedelta
import logging

import requests
from datetime import timedelta

from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/sensor/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rest/
"""
from datetime import timedelta
from json import loads
import logging

import requests
from json import loads
from datetime import timedelta

from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
Expand Down
11 changes: 3 additions & 8 deletions homeassistant/components/sensor/rpi_gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rpi_gpio/
"""
# pylint: disable=import-error
import logging
from homeassistant.helpers.entity import Entity

try:
import RPi.GPIO as GPIO
except ImportError:
GPIO = None
from homeassistant.const import (DEVICE_DEFAULT_NAME,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP)
Expand All @@ -29,10 +26,7 @@
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Raspberry PI GPIO ports. """
if GPIO is None:
_LOGGER.error('RPi.GPIO not available. rpi_gpio ports ignored.')
return
# pylint: disable=no-member
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

sensors = []
Expand Down Expand Up @@ -65,6 +59,7 @@ class RPiGPIOSensor(Entity):
def __init__(self, port_name, port_num, pull_mode,
value_high, value_low, bouncetime):
# pylint: disable=no-member
import RPi.GPIO as GPIO
self._name = port_name or DEVICE_DEFAULT_NAME
self._port = port_num
self._pull = GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/sensor/sabnzbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.sabnzbd/
"""
from homeassistant.util import Throttle
from datetime import timedelta
import logging

from homeassistant.helpers.entity import Entity

import logging
from homeassistant.util import Throttle

REQUIREMENTS = ['https://github.com/jamespcole/home-assistant-nzb-clients/'
'archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip'
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/sensor/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.transmission/
"""
from homeassistant.util import Throttle
from datetime import timedelta
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
import logging

from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity

import logging

REQUIREMENTS = ['transmissionrpc==0.11']
SENSOR_TYPES = {
'current_status': ['Status', ''],
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sensor/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def unit_of_measurement(self):

@property
def state_attributes(self):
attr = super().state_attributes
attr = {}
if self.vera_device.has_battery:
attr[ATTR_BATTERY_LEVEL] = self.vera_device.battery_level + '%'

Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/sensor/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
For more details about this platform, please refer to the documentation
at https://home-assistant.io/components/zwave/
"""
# Because we do not compile openzwave on CI
# pylint: disable=import-error
from homeassistant.helpers.event import track_point_in_time
import datetime

from homeassistant.helpers.event import track_point_in_time
import homeassistant.util.dt as dt_util
import homeassistant.components.zwave as zwave
from homeassistant.helpers.entity import Entity
Expand Down
Loading

0 comments on commit a301d86

Please sign in to comment.