Pylint 2 fixes (#15487)

* pylint 2 inline disable syntax fixes

* pylint 2 logging-not-lazy fixes

* pylint 2 consider-using-in fixes

* Revert pylint 2 inline disable syntax fixes addressing unused-imports

Will have a go at removing more unused imports altogether first.
This commit is contained in:
Ville Skyttä authored and Paulus Schoutsen committed 2018-07-17 19:34:29 +02:00
1 parent d2f4bce6c0
commit e31dd4404e
33 files changed
+55 -73

No files matched your search

+3 -7
View File
@@ -56,9 +56,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
SENSOR_TYPES[sensor_type][0], arlo, sensor_type))
else:
for camera in arlo.cameras:
if sensor_type == 'temperature' or \
sensor_type == 'humidity' or \
sensor_type == 'air_quality':
if sensor_type in ('temperature', 'humidity', 'air_quality'):
continue
name = '{0} {1}'.format(
@@ -66,10 +64,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
sensors.append(ArloSensor(name, camera, sensor_type))
for base_station in arlo.base_stations:
if ((sensor_type == 'temperature' or
sensor_type == 'humidity' or
sensor_type == 'air_quality') and
base_station.model_id == 'ABC1000'):
if sensor_type in ('temperature', 'humidity', 'air_quality') \
and base_station.model_id == 'ABC1000':
name = '{0} {1}'.format(
SENSOR_TYPES[sensor_type][0], base_station.name)
sensors.append(ArloSensor(name, base_station, sensor_type))
+1 -1
View File
@@ -85,7 +85,7 @@ class DaikinClimateSensor(Entity):
if value is None:
_LOGGER.warning("Invalid value requested for key %s", key)
else:
if value == "-" or value == "--":
if value in ("-", "--"):
value = None
elif cast_to_float:
try:
@@ -70,7 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
phonebook = FritzBoxPhonebook(
host=host, port=port, username=username, password=password,
phonebook_id=phonebook_id, prefixes=prefixes)
except: # noqa: E722 # pylint: disable=bare-except
except: # noqa: E722 pylint: disable=bare-except
phonebook = None
_LOGGER.warning("Phonebook with ID %s not found on Fritz!Box",
phonebook_id)
+2 -2
View File
@@ -86,8 +86,8 @@ class IOSSensor(Entity):
battery_level = device_battery[ios.ATTR_BATTERY_LEVEL]
charging = True
icon_state = DEFAULT_ICON_STATE
if (battery_state == ios.ATTR_BATTERY_STATE_FULL or
battery_state == ios.ATTR_BATTERY_STATE_UNPLUGGED):
if battery_state in (ios.ATTR_BATTERY_STATE_FULL,
ios.ATTR_BATTERY_STATE_UNPLUGGED):
charging = False
icon_state = "{}-off".format(DEFAULT_ICON_STATE)
elif battery_state == ios.ATTR_BATTERY_STATE_UNKNOWN:
+1 -2
View File
@@ -259,8 +259,7 @@ class ISYSensorDevice(ISYDevice):
if len(self._node.uom) == 1:
if self._node.uom[0] in UOM_FRIENDLY_NAME:
friendly_name = UOM_FRIENDLY_NAME.get(self._node.uom[0])
if friendly_name == TEMP_CELSIUS or \
friendly_name == TEMP_FAHRENHEIT:
if friendly_name in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
friendly_name = self.hass.config.units.temperature_unit
return friendly_name
else:
+1 -1
View File
@@ -62,7 +62,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the MiFlora sensor."""
from miflora import miflora_poller
try:
import bluepy.btle # noqa: F401 # pylint: disable=unused-variable
import bluepy.btle # noqa: F401 pylint: disable=unused-variable
from btlewrap import BluepyBackend
backend = BluepyBackend
except ImportError:
+1 -1
View File
@@ -60,7 +60,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the MiTempBt sensor."""
from mitemp_bt import mitemp_bt_poller
try:
import bluepy.btle # noqa: F401 # pylint: disable=unused-variable
import bluepy.btle # noqa: F401 pylint: disable=unused-variable
from btlewrap import BluepyBackend
backend = BluepyBackend
except ImportError:
+1 -1
View File
@@ -107,7 +107,7 @@ class OctoPrintSensor(Entity):
def state(self):
"""Return the state of the sensor."""
sensor_unit = self.unit_of_measurement
if sensor_unit == TEMP_CELSIUS or sensor_unit == "%":
if sensor_unit in (TEMP_CELSIUS, "%"):
# API sometimes returns null and not 0
if self._state is None:
self._state = 0
+1 -1
View File
@@ -192,7 +192,7 @@ class QNAPStatsAPI(object):
self.data["smart_drive_health"] = self._api.get_smart_disk_health()
self.data["volumes"] = self._api.get_volumes()
self.data["bandwidth"] = self._api.get_bandwidth()
except: # noqa: E722 # pylint: disable=bare-except
except: # noqa: E722 pylint: disable=bare-except
_LOGGER.exception("Failed to fetch QNAP stats from the NAS")
@@ -140,7 +140,7 @@ class SynoApi(object):
try:
self._api = SynologyDSM(host, port, username, password,
use_https=use_ssl)
except: # noqa: E722 # pylint: disable=bare-except
except: # noqa: E722 pylint: disable=bare-except
_LOGGER.error("Error setting up Synology DSM")
# Will be updated when update() gets called.