Fix pylint 1.7.2 no-else-return issues (#8361)
* Fix pylint 1.7.2 no-else-return issues * Update tomato.py
This commit is contained in:
1 parent
5779d64e98
commit
46e030662d
111 files changed
+305
-455
No files matched your search
@@ -146,7 +146,4 @@ class ArwnSensor(Entity):
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of device based on its type."""
|
||||
if self._icon:
|
||||
return self._icon
|
||||
else:
|
||||
return super().icon
|
||||
return self._icon
|
||||
@@ -139,17 +139,17 @@ class BOMCurrentSensor(Entity):
|
||||
"""Return the name of the sensor."""
|
||||
if self.stationname is None:
|
||||
return 'BOM {}'.format(SENSOR_TYPES[self._condition][0])
|
||||
else:
|
||||
return 'BOM {} {}'.format(
|
||||
self.stationname, SENSOR_TYPES[self._condition][0])
|
||||
|
||||
return 'BOM {} {}'.format(
|
||||
self.stationname, SENSOR_TYPES[self._condition][0])
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
if self.rest.data and self._condition in self.rest.data:
|
||||
return self.rest.data[self._condition]
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -167,8 +167,8 @@ class BrSensor(Entity):
|
||||
|
||||
if self.type != SYMBOL:
|
||||
return None
|
||||
else:
|
||||
return self._entity_picture
|
||||
|
||||
return self._entity_picture
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -187,9 +187,9 @@ class DarkSkySensor(Entity):
|
||||
"""Return the name of the sensor."""
|
||||
if self.forecast_day == 0:
|
||||
return '{} {}'.format(self.client_name, self._name)
|
||||
else:
|
||||
return '{} {} {}'.format(
|
||||
self.client_name, self._name, self.forecast_day)
|
||||
|
||||
return '{} {} {}'.format(
|
||||
self.client_name, self._name, self.forecast_day)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -214,8 +214,8 @@ class DarkSkySensor(Entity):
|
||||
|
||||
if self._icon in CONDITION_PICTURES:
|
||||
return CONDITION_PICTURES[self._icon]
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
def update_unit_of_measurement(self):
|
||||
"""Update units based on unit system."""
|
||||
|
||||
@@ -207,11 +207,11 @@ class DSMREntity(Entity):
|
||||
|
||||
if self._obis == obis.ELECTRICITY_ACTIVE_TARIFF:
|
||||
return self.translate_tariff(value)
|
||||
else:
|
||||
if value is not None:
|
||||
return value
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
|
||||
if value is not None:
|
||||
return value
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
@@ -227,8 +227,8 @@ class DSMREntity(Entity):
|
||||
return 'normal'
|
||||
elif value == '0001':
|
||||
return 'low'
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
|
||||
class DerivativeDSMREntity(DSMREntity):
|
||||
|
||||
@@ -59,8 +59,7 @@ class DysonFilterLifeSensor(Entity):
|
||||
"""Return filter life in hours.."""
|
||||
if self._device.state:
|
||||
return self._device.state.filter_life
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
@@ -86,8 +86,7 @@ def get_from_conf(config, config_key, length):
|
||||
_LOGGER.error("Error in config parameter %s: Must be exactly %d "
|
||||
"bytes. Device will not be added", config_key, length/2)
|
||||
return None
|
||||
else:
|
||||
return string
|
||||
return string
|
||||
|
||||
|
||||
class EddystoneTemp(Entity):
|
||||
|
||||
@@ -155,8 +155,8 @@ class EightUserSensor(EightSleepUserEntity):
|
||||
elif 'bed_temp' in self._sensor:
|
||||
if self._units == 'si':
|
||||
return '°C'
|
||||
else:
|
||||
return '°F'
|
||||
return '°F'
|
||||
return None
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
@@ -264,8 +264,7 @@ class EightRoomSensor(EightSleepUserEntity):
|
||||
"""Return the unit the value is expressed in."""
|
||||
if self._units == 'si':
|
||||
return '°C'
|
||||
else:
|
||||
return '°F'
|
||||
return '°F'
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
||||
@@ -91,10 +91,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_stop_listener
|
||||
)
|
||||
|
||||
if monitor.sock is None:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return monitor.sock is not None
|
||||
|
||||
|
||||
class FritzBoxCallSensor(Entity):
|
||||
@@ -118,10 +115,7 @@ class FritzBoxCallSensor(Entity):
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Only poll to update phonebook, if defined."""
|
||||
if self.phonebook is None:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return self.phonebook is not None
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -142,8 +136,7 @@ class FritzBoxCallSensor(Entity):
|
||||
"""Return a name for a given phone number."""
|
||||
if self.phonebook is None:
|
||||
return 'unknown'
|
||||
else:
|
||||
return self.phonebook.get_name(number)
|
||||
return self.phonebook.get_name(number)
|
||||
|
||||
def update(self):
|
||||
"""Update the phonebook if it is defined."""
|
||||
|
||||
@@ -89,8 +89,7 @@ class GlancesSensor(Entity):
|
||||
"""Return the name of the sensor."""
|
||||
if self._name is None:
|
||||
return SENSOR_TYPES[self.type][0]
|
||||
else:
|
||||
return '{} {}'.format(self._name, SENSOR_TYPES[self.type][0])
|
||||
return '{} {}'.format(self._name, SENSOR_TYPES[self.type][0])
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
||||
@@ -94,8 +94,7 @@ class GpsdSensor(Entity):
|
||||
return "3D Fix"
|
||||
elif self.agps_thread.data_stream.mode == 2:
|
||||
return "2D Fix"
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -77,8 +77,7 @@ class HddTempSensor(Entity):
|
||||
"""Return the unit the value is expressed in."""
|
||||
if self._details[4] == 'C':
|
||||
return TEMP_CELSIUS
|
||||
else:
|
||||
return TEMP_FAHRENHEIT
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -296,8 +296,7 @@ class HistoryStatsHelper:
|
||||
return '%dd %dh %dm' % (days, hours, minutes)
|
||||
elif hours > 0:
|
||||
return '%dh %dm' % (hours, minutes)
|
||||
else:
|
||||
return '%dm' % minutes
|
||||
return '%dm' % minutes
|
||||
|
||||
@staticmethod
|
||||
def pretty_ratio(value, period):
|
||||
|
||||
@@ -121,8 +121,7 @@ class IOSSensor(Entity):
|
||||
|
||||
if self.type == "state":
|
||||
return returning_icon_state
|
||||
else:
|
||||
return returning_icon_level
|
||||
return returning_icon_level
|
||||
|
||||
def update(self):
|
||||
"""Get the latest state of the sensor."""
|
||||
|
||||
@@ -310,8 +310,7 @@ class ISYSensorDevice(isy.ISYDevice):
|
||||
raw_units = self.raw_unit_of_measurement
|
||||
if raw_units in (TEMP_FAHRENHEIT, TEMP_CELSIUS):
|
||||
return self.hass.config.units.temperature_unit
|
||||
else:
|
||||
return raw_units
|
||||
return raw_units
|
||||
|
||||
|
||||
class ISYWeatherDevice(isy.ISYDevice):
|
||||
|
||||
@@ -105,8 +105,7 @@ class KWBSensor(Entity):
|
||||
"""Return the state of value."""
|
||||
if self._sensor.value is not None and self._sensor.available:
|
||||
return self._sensor.value
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
||||
@@ -124,10 +124,8 @@ class MetOfficeCurrentSensor(Entity):
|
||||
if self._condition == "weather":
|
||||
return [k for k, v in CONDITION_CLASSES.items() if
|
||||
self.data.data.weather.value in v][0]
|
||||
else:
|
||||
return variable.value
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return variable.value
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
||||
@@ -64,8 +64,7 @@ class MoonSensor(Entity):
|
||||
return 'Waning gibbous'
|
||||
elif self._state == 21:
|
||||
return 'Last quarter'
|
||||
else:
|
||||
return 'Waning crescent'
|
||||
return 'Waning crescent'
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
||||
@@ -91,8 +91,7 @@ class MVGLiveSensor(Entity):
|
||||
"""Return the name of the sensor."""
|
||||
if self._name:
|
||||
return self._name
|
||||
else:
|
||||
return self._station
|
||||
return self._station
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
@@ -136,10 +136,7 @@ class NeatoConnectedSensor(Entity):
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if sensor data is available."""
|
||||
if not self._state:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
@@ -14,7 +14,7 @@ import voluptuous as vol
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_PORT, STATE_UNKNOWN, CONF_NAME, CONF_RESOURCES)
|
||||
CONF_HOST, CONF_PORT, CONF_NAME, CONF_RESOURCES)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -110,8 +110,7 @@ class NetdataSensor(Entity):
|
||||
netdata_id = SENSOR_TYPES[self.type][3]
|
||||
if netdata_id in value:
|
||||
return "{0:.{1}f}".format(value[netdata_id], self._precision)
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return None
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
||||
@@ -60,8 +60,7 @@ class OhmconnectSensor(Entity):
|
||||
"""Return the state of the sensor."""
|
||||
if self._data.get("active") == "True":
|
||||
return "Active"
|
||||
else:
|
||||
return "Inactive"
|
||||
return "Inactive"
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -15,8 +15,7 @@ from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.components.sensor.rest import RestData
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE, CONF_API_KEY, CONF_NAME, STATE_UNKNOWN, ATTR_DATE,
|
||||
ATTR_TIME)
|
||||
ATTR_TEMPERATURE, CONF_API_KEY, CONF_NAME, ATTR_DATE, ATTR_TIME)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_ENDPOINT = 'http://pvoutput.org/service/r2/getstatus.jsp'
|
||||
@@ -90,8 +89,7 @@ class PvoutputSensor(Entity):
|
||||
"""Return the state of the device."""
|
||||
if self.pvcoutput is not None:
|
||||
return self.pvcoutput.energy_generation
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return None
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -232,8 +232,7 @@ class QNAPSensor(Entity):
|
||||
if self.monitor_device is not None:
|
||||
return "{} {} ({})".format(
|
||||
server_name, self.var_name, self.monitor_device)
|
||||
else:
|
||||
return "{} {}".format(server_name, self.var_name)
|
||||
return "{} {}".format(server_name, self.var_name)
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
||||
@@ -90,8 +90,7 @@ class SwissHydrologicalDataSensor(Entity):
|
||||
"""Return the unit of measurement of this entity, if any."""
|
||||
if self._state is not STATE_UNKNOWN:
|
||||
return self._unit_of_measurement
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
@@ -177,8 +177,7 @@ class SynoNasSensor(Entity):
|
||||
"""Return the name of the sensor, if any."""
|
||||
if self.monitor_device is not None:
|
||||
return "{} ({})".format(self.var_name, self.monitor_device)
|
||||
else:
|
||||
return self.var_name
|
||||
return self.var_name
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
@@ -191,8 +190,7 @@ class SynoNasSensor(Entity):
|
||||
if self.var_id in ['volume_disk_temp_avg', 'volume_disk_temp_max',
|
||||
'disk_temp']:
|
||||
return self._api.temp_unit
|
||||
else:
|
||||
return self.var_units
|
||||
return self.var_units
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data for the states."""
|
||||
@@ -238,8 +236,8 @@ class SynoNasStorageSensor(SynoNasSensor):
|
||||
|
||||
if self._api.temp_unit == TEMP_CELSIUS:
|
||||
return attr
|
||||
else:
|
||||
return round(attr * 1.8 + 32.0, 1)
|
||||
else:
|
||||
return getattr(self._api.storage,
|
||||
self.var_id)(self.monitor_device)
|
||||
|
||||
return round(attr * 1.8 + 32.0, 1)
|
||||
|
||||
return getattr(self._api.storage,
|
||||
self.var_id)(self.monitor_device)
|
||||
@@ -30,7 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
zones = tado.get_zones()
|
||||
except RuntimeError:
|
||||
_LOGGER.error("Unable to get zone info from mytado")
|
||||
return False
|
||||
return
|
||||
|
||||
sensor_items = []
|
||||
for zone in zones:
|
||||
@@ -47,9 +47,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
if sensor_items:
|
||||
add_devices(sensor_items, True)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def create_zone_sensor(tado, zone, name, zone_id, variable):
|
||||
|
||||
@@ -92,8 +92,7 @@ class TelldusLiveSensor(TelldusLiveEntity):
|
||||
return self._value_as_humidity
|
||||
elif self._type == SENSOR_TYPE_LUMINANCE:
|
||||
return self._value_as_luminance
|
||||
else:
|
||||
return self._value
|
||||
return self._value
|
||||
|
||||
@property
|
||||
def quantity_name(self):
|
||||
|
||||
@@ -83,8 +83,7 @@ class TimeDateSensor(Entity):
|
||||
return 'mdi:calendar-clock'
|
||||
elif 'date' in self.type:
|
||||
return 'mdi:calendar'
|
||||
else:
|
||||
return 'mdi:clock'
|
||||
return 'mdi:clock'
|
||||
|
||||
def get_next_interval(self, now=None):
|
||||
"""Compute next time an update should occur."""
|
||||
|
||||
@@ -28,8 +28,7 @@ class VolvoSensor(VolvoEntity):
|
||||
val = getattr(self.vehicle, self._attribute)
|
||||
if self._attribute == 'odometer':
|
||||
return round(val / 1000) # km
|
||||
else:
|
||||
return val
|
||||
return val
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION, ATTR_TIME, ATTR_TEMPERATURE, STATE_UNKNOWN, CONF_TOKEN)
|
||||
ATTR_ATTRIBUTION, ATTR_TIME, ATTR_TEMPERATURE, CONF_TOKEN)
|
||||
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
@@ -101,8 +101,7 @@ class WaqiSensor(Entity):
|
||||
"""Return the state of the device."""
|
||||
if self._details is not None:
|
||||
return self._details.get('aqi')
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return None
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
||||
@@ -254,8 +254,7 @@ class WUAlertsSensorConfig(WUSensorConfig):
|
||||
feature="alerts",
|
||||
value=lambda wu: len(wu.data['alerts']),
|
||||
icon=lambda wu: "mdi:alert-circle-outline"
|
||||
if len(wu.data['alerts']) > 0
|
||||
else "mdi:check-circle-outline",
|
||||
if wu.data['alerts'] else "mdi:check-circle-outline",
|
||||
device_state_attributes=self._get_attributes
|
||||
)
|
||||
|
||||
|
||||
@@ -78,8 +78,7 @@ class ZWaveMultilevelSensor(ZWaveSensor):
|
||||
return TEMP_CELSIUS
|
||||
elif self._units == 'F':
|
||||
return TEMP_FAHRENHEIT
|
||||
else:
|
||||
return self._units
|
||||
return self._units
|
||||
|
||||
|
||||
class ZWaveAlarmSensor(ZWaveSensor):
|
||||
|
||||
Reference in new issue
Block a user