Upgrade pylint to 1.8.2 (#12274)
* Upgrade pylint to 1.8.1 * Fix no-else-return * Fix bad-whitespace * Fix too-many-nested-blocks * Fix raising-format-tuple See https://github.com/PyCQA/pylint/blob/master/doc/whatsnew/1.8.rst * Fix len-as-condition * Fix logging-not-lazy Not sure about that TEMP_CELSIUS though, but internally it's probably just like if you concatenated any other (variable) string * Fix stop-iteration-return * Fix useless-super-delegation * Fix trailing-comma-tuple Both of these seem to simply be bugs: * Nest: The value of self._humidity never seems to be used anywhere * Dovado: The called API method seems to expect a "normal" number * Fix redefined-argument-from-local * Fix consider-using-enumerate * Fix wrong-import-order * Fix arguments-differ * Fix missed no-else-return * Fix no-member and related * Fix signatures-differ * Revert "Upgrade pylint to 1.8.1" This reverts commit af78aa00f125a7d34add97b9d50c14db48412211. * Fix arguments-differ * except for device_tracker * Cleanup * Fix test using positional argument * Fix line too long I forgot to run flake8 - shame on me... 🙃 * Fix bad-option-value for 1.6.5 * Fix arguments-differ for device_tracker * Upgrade pylint to 1.8.2 * 👕 Fix missed no-member
This commit is contained in:
1 parent
64c5d26a84
commit
678f284015
196 files changed
+541
-593
No files matched your search
@@ -116,7 +116,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
return
|
||||
|
||||
|
||||
# pylint: disable=import-error
|
||||
# pylint: disable=import-error, no-member
|
||||
def _setup_bme680(config):
|
||||
"""Set up and configure the BME680 sensor."""
|
||||
from smbus import SMBus
|
||||
|
||||
@@ -128,7 +128,7 @@ class CupsSensor(Entity):
|
||||
self._printer = self.data.printers.get(self._name)
|
||||
|
||||
|
||||
# pylint: disable=import-error
|
||||
# pylint: disable=import-error, no-name-in-module
|
||||
class CupsData(object):
|
||||
"""Get the latest data from CUPS and update the state."""
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class Dovado:
|
||||
|
||||
def send_sms(service):
|
||||
"""Send SMS through the router."""
|
||||
number = service.data.get('number'),
|
||||
number = service.data.get('number')
|
||||
message = service.data.get('message')
|
||||
_LOGGER.debug("message for %s: %s", number, message)
|
||||
self._dovado.send_sms(number, message)
|
||||
|
||||
@@ -9,13 +9,14 @@ from datetime import timedelta
|
||||
from functools import partial
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, STATE_UNKNOWN)
|
||||
from homeassistant.core import CoreState
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import voluptuous as vol
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -137,11 +137,11 @@ class DwdWeatherWarningsSensor(Entity):
|
||||
data['warning_{}_name'.format(i)] = event['event']
|
||||
data['warning_{}_level'.format(i)] = event['level']
|
||||
data['warning_{}_type'.format(i)] = event['type']
|
||||
if len(event['headline']) > 0:
|
||||
if event['headline']:
|
||||
data['warning_{}_headline'.format(i)] = event['headline']
|
||||
if len(event['description']) > 0:
|
||||
if event['description']:
|
||||
data['warning_{}_description'.format(i)] = event['description']
|
||||
if len(event['instruction']) > 0:
|
||||
if event['instruction']:
|
||||
data['warning_{}_instruction'.format(i)] = event['instruction']
|
||||
|
||||
if event['start'] is not None:
|
||||
|
||||
@@ -6,6 +6,7 @@ https://home-assistant.io/components/sensor.fritzbox_netmonitor/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -15,8 +16,6 @@ from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
REQUIREMENTS = ['fritzconnection==0.6.5']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -172,4 +172,4 @@ class HpIloData(object):
|
||||
password=self._password, port=self._port)
|
||||
except (hpilo.IloError, hpilo.IloCommunicationError,
|
||||
hpilo.IloLoginFailed) as error:
|
||||
raise ValueError("Unable to init HP ILO, %s", error)
|
||||
raise ValueError("Unable to init HP ILO, {}".format(error))
|
||||
@@ -62,7 +62,7 @@ class IHCSensor(IHCDevice, Entity):
|
||||
"""Implementation of the IHC sensor."""
|
||||
|
||||
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
|
||||
unit, product: Element=None) -> None:
|
||||
unit, product: Element = None) -> None:
|
||||
"""Initialize the IHC sensor."""
|
||||
super().__init__(ihc_controller, name, ihc_id, info, product)
|
||||
self._state = None
|
||||
|
||||
@@ -92,7 +92,7 @@ class IrishRailTransportSensor(Entity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
if len(self._times) > 0:
|
||||
if self._times:
|
||||
next_up = "None"
|
||||
if len(self._times) > 1:
|
||||
next_up = self._times[1][ATTR_ORIGIN] + " to "
|
||||
@@ -126,7 +126,7 @@ class IrishRailTransportSensor(Entity):
|
||||
"""Get the latest data and update the states."""
|
||||
self.data.update()
|
||||
self._times = self.data.info
|
||||
if len(self._times) > 0:
|
||||
if self._times:
|
||||
self._state = self._times[0][ATTR_DUE_IN]
|
||||
else:
|
||||
self._state = None
|
||||
@@ -164,7 +164,7 @@ class IrishRailTransportData(object):
|
||||
ATTR_TRAIN_TYPE: train.get('type')}
|
||||
self.info.append(train_data)
|
||||
|
||||
if not self.info or len(self.info) == 0:
|
||||
if not self.info or not self.info:
|
||||
self.info = self._empty_train_data()
|
||||
|
||||
def _empty_train_data(self):
|
||||
|
||||
@@ -254,10 +254,6 @@ def setup_platform(hass, config: ConfigType,
|
||||
class ISYSensorDevice(ISYDevice):
|
||||
"""Representation of an ISY994 sensor device."""
|
||||
|
||||
def __init__(self, node) -> None:
|
||||
"""Initialize the ISY994 sensor device."""
|
||||
super().__init__(node)
|
||||
|
||||
@property
|
||||
def raw_unit_of_measurement(self) -> str:
|
||||
"""Get the raw unit of measurement for the ISY994 sensor device."""
|
||||
@@ -313,10 +309,6 @@ class ISYSensorDevice(ISYDevice):
|
||||
class ISYWeatherDevice(ISYDevice):
|
||||
"""Representation of an ISY994 weather device."""
|
||||
|
||||
def __init__(self, node) -> None:
|
||||
"""Initialize the ISY994 weather device."""
|
||||
super().__init__(node)
|
||||
|
||||
@property
|
||||
def raw_units(self) -> str:
|
||||
"""Return the raw unit of measurement."""
|
||||
|
||||
@@ -133,10 +133,6 @@ class LaCrosseSensor(Entity):
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
def update(self, *args):
|
||||
"""Get the latest data."""
|
||||
pass
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
||||
@@ -119,24 +119,23 @@ class LinuxBatterySensor(Entity):
|
||||
ATTR_HEALTH: self._battery_stat.health,
|
||||
ATTR_STATUS: self._battery_stat.status,
|
||||
}
|
||||
else:
|
||||
return {
|
||||
ATTR_NAME: self._battery_stat.name,
|
||||
ATTR_PATH: self._battery_stat.path,
|
||||
ATTR_ALARM: self._battery_stat.alarm,
|
||||
ATTR_CAPACITY_LEVEL: self._battery_stat.capacity_level,
|
||||
ATTR_CYCLE_COUNT: self._battery_stat.cycle_count,
|
||||
ATTR_ENERGY_FULL: self._battery_stat.energy_full,
|
||||
ATTR_ENERGY_FULL_DESIGN: self._battery_stat.energy_full_design,
|
||||
ATTR_ENERGY_NOW: self._battery_stat.energy_now,
|
||||
ATTR_MANUFACTURER: self._battery_stat.manufacturer,
|
||||
ATTR_MODEL_NAME: self._battery_stat.model_name,
|
||||
ATTR_POWER_NOW: self._battery_stat.power_now,
|
||||
ATTR_SERIAL_NUMBER: self._battery_stat.serial_number,
|
||||
ATTR_STATUS: self._battery_stat.status,
|
||||
ATTR_VOLTAGE_MIN_DESIGN: self._battery_stat.voltage_min_design,
|
||||
ATTR_VOLTAGE_NOW: self._battery_stat.voltage_now,
|
||||
}
|
||||
return {
|
||||
ATTR_NAME: self._battery_stat.name,
|
||||
ATTR_PATH: self._battery_stat.path,
|
||||
ATTR_ALARM: self._battery_stat.alarm,
|
||||
ATTR_CAPACITY_LEVEL: self._battery_stat.capacity_level,
|
||||
ATTR_CYCLE_COUNT: self._battery_stat.cycle_count,
|
||||
ATTR_ENERGY_FULL: self._battery_stat.energy_full,
|
||||
ATTR_ENERGY_FULL_DESIGN: self._battery_stat.energy_full_design,
|
||||
ATTR_ENERGY_NOW: self._battery_stat.energy_now,
|
||||
ATTR_MANUFACTURER: self._battery_stat.manufacturer,
|
||||
ATTR_MODEL_NAME: self._battery_stat.model_name,
|
||||
ATTR_POWER_NOW: self._battery_stat.power_now,
|
||||
ATTR_SERIAL_NUMBER: self._battery_stat.serial_number,
|
||||
ATTR_STATUS: self._battery_stat.status,
|
||||
ATTR_VOLTAGE_MIN_DESIGN: self._battery_stat.voltage_min_design,
|
||||
ATTR_VOLTAGE_NOW: self._battery_stat.voltage_now,
|
||||
}
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data and updates the states."""
|
||||
|
||||
@@ -174,7 +174,7 @@ class MoldIndicator(Entity):
|
||||
self._dewpoint = \
|
||||
MAGNUS_K3 * (alpha + math.log(self._indoor_hum / 100.0)) / \
|
||||
(beta - math.log(self._indoor_hum / 100.0))
|
||||
_LOGGER.debug("Dewpoint: %f " + TEMP_CELSIUS, self._dewpoint)
|
||||
_LOGGER.debug("Dewpoint: %f %s", self._dewpoint, TEMP_CELSIUS)
|
||||
|
||||
def _calc_moldindicator(self):
|
||||
"""Calculate the humidity at the (cold) calibration point."""
|
||||
@@ -192,8 +192,8 @@ class MoldIndicator(Entity):
|
||||
self._outdoor_temp + (self._indoor_temp - self._outdoor_temp) / \
|
||||
self._calib_factor
|
||||
|
||||
_LOGGER.debug("Estimated Critical Temperature: %f " +
|
||||
TEMP_CELSIUS, self._crit_temp)
|
||||
_LOGGER.debug("Estimated Critical Temperature: %f %s",
|
||||
self._crit_temp, TEMP_CELSIUS)
|
||||
|
||||
# Then calculate the humidity at this point
|
||||
alpha = MAGNUS_K2 * self._crit_temp / (MAGNUS_K3 + self._crit_temp)
|
||||
|
||||
@@ -71,7 +71,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
NSDepartureSensor(
|
||||
nsapi, departure.get(CONF_NAME), departure.get(CONF_FROM),
|
||||
departure.get(CONF_TO), departure.get(CONF_VIA)))
|
||||
if len(sensors):
|
||||
if sensors:
|
||||
add_devices(sensors, True)
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ https://home-assistant.io/components/sensor.qnap/
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import (
|
||||
@@ -15,8 +17,6 @@ from homeassistant.const import (
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
REQUIREMENTS = ['qnapstats==0.2.4']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -140,7 +140,7 @@ class Monitor(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
"""Thread that keeps connection alive."""
|
||||
# pylint: disable=import-error
|
||||
# pylint: disable=import-error, no-name-in-module, no-member
|
||||
import pygatt
|
||||
from pygatt.backends import Characteristic
|
||||
from pygatt.exceptions import (
|
||||
|
||||
@@ -173,7 +173,7 @@ class StatisticsSensor(Entity):
|
||||
"""Remove states which are older than self._max_age."""
|
||||
now = dt_util.utcnow()
|
||||
|
||||
while (len(self.ages) > 0) and (now - self.ages[0]) > self._max_age:
|
||||
while self.ages and (now - self.ages[0]) > self._max_age:
|
||||
self.ages.popleft()
|
||||
self.states.popleft()
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ https://home-assistant.io/components/sensor.teksavvy/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import asyncio
|
||||
import async_timeout
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY, CONF_MONITORED_VARIABLES, CONF_NAME)
|
||||
@@ -16,7 +18,6 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
import voluptuous as vol
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -142,18 +143,17 @@ class TekSavvyData(object):
|
||||
if req.status != 200:
|
||||
_LOGGER.error("Request failed with status: %u", req.status)
|
||||
return False
|
||||
else:
|
||||
data = yield from req.json()
|
||||
for (api, ha_name) in API_HA_MAP:
|
||||
self.data[ha_name] = float(data["value"][0][api])
|
||||
on_peak_download = self.data["onpeak_download"]
|
||||
on_peak_upload = self.data["onpeak_upload"]
|
||||
off_peak_download = self.data["offpeak_download"]
|
||||
off_peak_upload = self.data["offpeak_upload"]
|
||||
limit = self.data["limit"]
|
||||
self.data["usage"] = 100*on_peak_download/self.bandwidth_cap
|
||||
self.data["usage_gb"] = on_peak_download
|
||||
self.data["onpeak_total"] = on_peak_download + on_peak_upload
|
||||
self.data["offpeak_total"] = off_peak_download + off_peak_upload
|
||||
self.data["onpeak_remaining"] = limit - on_peak_download
|
||||
return True
|
||||
data = yield from req.json()
|
||||
for (api, ha_name) in API_HA_MAP:
|
||||
self.data[ha_name] = float(data["value"][0][api])
|
||||
on_peak_download = self.data["onpeak_download"]
|
||||
on_peak_upload = self.data["onpeak_upload"]
|
||||
off_peak_download = self.data["offpeak_download"]
|
||||
off_peak_upload = self.data["offpeak_upload"]
|
||||
limit = self.data["limit"]
|
||||
self.data["usage"] = 100*on_peak_download/self.bandwidth_cap
|
||||
self.data["usage_gb"] = on_peak_download
|
||||
self.data["onpeak_total"] = on_peak_download + on_peak_upload
|
||||
self.data["offpeak_total"] = off_peak_download + off_peak_upload
|
||||
self.data["onpeak_remaining"] = limit - on_peak_download
|
||||
return True
|
||||
@@ -76,9 +76,8 @@ def async_http_request(hass, uri):
|
||||
req = yield from session.get(uri)
|
||||
if req.status != 200:
|
||||
return {'error': req.status}
|
||||
else:
|
||||
json_response = yield from req.json()
|
||||
return json_response
|
||||
json_response = yield from req.json()
|
||||
return json_response
|
||||
except (asyncio.TimeoutError, aiohttp.ClientError) as exc:
|
||||
_LOGGER.error("Cannot connect to ViaggiaTreno API endpoint: %s", exc)
|
||||
except ValueError:
|
||||
|
||||
@@ -42,12 +42,10 @@ class VolvoSensor(VolvoEntity):
|
||||
val /= 10 # L/1000km -> L/100km
|
||||
if 'mil' in self.unit_of_measurement:
|
||||
return round(val, 2)
|
||||
else:
|
||||
return round(val, 1)
|
||||
return round(val, 1)
|
||||
elif self._attribute == 'distance_to_empty':
|
||||
return int(floor(val))
|
||||
else:
|
||||
return int(round(val))
|
||||
return int(round(val))
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
@@ -56,8 +54,7 @@ class VolvoSensor(VolvoEntity):
|
||||
if self._state.config[CONF_SCANDINAVIAN_MILES] and 'km' in unit:
|
||||
if self._attribute == 'average_fuel_consumption':
|
||||
return 'L/mil'
|
||||
else:
|
||||
return unit.replace('km', 'mil')
|
||||
return unit.replace('km', 'mil')
|
||||
return unit
|
||||
|
||||
@property
|
||||
|
||||
@@ -90,10 +90,8 @@ class WorldTidesInfoSensor(Entity):
|
||||
tidetime = time.strftime('%I:%M %p', time.localtime(
|
||||
self.data['extremes'][0]['dt']))
|
||||
return "Low tide at %s" % (tidetime)
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data from WorldTidesInfo API."""
|
||||
|
||||
@@ -226,7 +226,7 @@ class YrData(object):
|
||||
|
||||
# Update all devices
|
||||
tasks = []
|
||||
if len(ordered_entries) > 0:
|
||||
if ordered_entries:
|
||||
for dev in self.devices:
|
||||
new_state = None
|
||||
|
||||
@@ -258,5 +258,5 @@ class YrData(object):
|
||||
dev._state = new_state
|
||||
tasks.append(dev.async_update_ha_state())
|
||||
|
||||
if len(tasks) > 0:
|
||||
if tasks:
|
||||
yield from asyncio.wait(tasks, loop=self.hass.loop)
|
||||
@@ -70,7 +70,7 @@ class ZigBeeTemperatureSensor(Entity):
|
||||
"""Return the unit of measurement the value is expressed in."""
|
||||
return TEMP_CELSIUS
|
||||
|
||||
def update(self, *args):
|
||||
def update(self):
|
||||
"""Get the latest data."""
|
||||
try:
|
||||
self._temp = zigbee.DEVICE.get_temperature(self._config.address)
|
||||
|
||||
Reference in new issue
Block a user