Pylint cleanups (#15626)

* Pylint 2 no-else-return fixes

* Remove unneeded abstract-class-not-used pylint disable
This commit is contained in:
Ville Skyttä authored and Paulus Schoutsen committed 2018-07-23 10:16:05 +02:00
1 parent a38c0d6d15
commit b7c336a687
166 files changed
+425 -490

No files matched your search

@@ -537,7 +537,7 @@ class Device(Entity):
"""
if not self.last_seen:
return
elif self.location_name:
if self.location_name:
self._state = self.location_name
elif self.gps is not None and self.source_type == SOURCE_TYPE_GPS:
zone_state = async_active_zone(
@@ -94,10 +94,10 @@ class ArubaDeviceScanner(DeviceScanner):
if query == 1:
_LOGGER.error("Timeout")
return
elif query == 2:
if query == 2:
_LOGGER.error("Unexpected response from router")
return
elif query == 3:
if query == 3:
ssh.sendline('yes')
ssh.expect('password:')
elif query == 4:
@@ -94,8 +94,7 @@ def _get_homehub_data(url):
return
if response.status_code == 200:
return _parse_homehub_response(response.text)
else:
_LOGGER.error("Invalid response from Home Hub: %s", response)
_LOGGER.error("Invalid response from Home Hub: %s", response)
def _parse_homehub_response(data_str):
@@ -131,13 +131,12 @@ class DdWrtDeviceScanner(DeviceScanner):
return
if response.status_code == 200:
return _parse_ddwrt_response(response.text)
elif response.status_code == 401:
if response.status_code == 401:
# Authentication error
_LOGGER.exception(
"Failed to authenticate, check your username and password")
return
else:
_LOGGER.error("Invalid response from DD-WRT: %s", response)
_LOGGER.error("Invalid response from DD-WRT: %s", response)
def _parse_ddwrt_response(data_str):
@@ -70,16 +70,15 @@ class GeofencyView(HomeAssistantView):
if self._is_mobile_beacon(data):
return (yield from self._set_location(hass, data, None))
if data['entry'] == LOCATION_ENTRY:
location_name = data['name']
else:
if data['entry'] == LOCATION_ENTRY:
location_name = data['name']
else:
location_name = STATE_NOT_HOME
if ATTR_CURRENT_LATITUDE in data:
data[ATTR_LATITUDE] = data[ATTR_CURRENT_LATITUDE]
data[ATTR_LONGITUDE] = data[ATTR_CURRENT_LONGITUDE]
location_name = STATE_NOT_HOME
if ATTR_CURRENT_LATITUDE in data:
data[ATTR_LATITUDE] = data[ATTR_CURRENT_LATITUDE]
data[ATTR_LONGITUDE] = data[ATTR_CURRENT_LONGITUDE]
return (yield from self._set_location(hass, data, location_name))
return (yield from self._set_location(hass, data, location_name))
@staticmethod
def _validate_data(data):
@@ -84,7 +84,7 @@ class LocativeView(HomeAssistantView):
gps=gps_location))
return 'Setting location to {}'.format(location_name)
elif direction == 'exit':
if direction == 'exit':
current_state = hass.states.get(
'{}.{}'.format(DOMAIN, device))
@@ -102,7 +102,7 @@ class LocativeView(HomeAssistantView):
return 'Ignoring exit from {} (already in {})'.format(
location_name, current_state)
elif direction == 'test':
if direction == 'test':
# In the app, a test message can be sent. Just return something to
# the user to let them know that it works.
return 'Received test message.'
@@ -74,17 +74,16 @@ class MerakiView(HomeAssistantView):
_LOGGER.error("Invalid Secret received from Meraki")
return self.json_message('Invalid secret',
HTTP_UNPROCESSABLE_ENTITY)
elif data['version'] != VERSION:
if data['version'] != VERSION:
_LOGGER.error("Invalid API version: %s", data['version'])
return self.json_message('Invalid version',
HTTP_UNPROCESSABLE_ENTITY)
else:
_LOGGER.debug('Valid Secret')
if data['type'] not in ('DevicesSeen', 'BluetoothDevicesSeen'):
_LOGGER.error("Unknown Device %s", data['type'])
return self.json_message('Invalid device type',
HTTP_UNPROCESSABLE_ENTITY)
_LOGGER.debug("Processing %s", data['type'])
_LOGGER.debug('Valid Secret')
if data['type'] not in ('DevicesSeen', 'BluetoothDevicesSeen'):
_LOGGER.error("Unknown Device %s", data['type'])
return self.json_message('Invalid device type',
HTTP_UNPROCESSABLE_ENTITY)
_LOGGER.debug("Processing %s", data['type'])
if not data["data"]["observations"]:
_LOGGER.debug("No observations found")
return
@@ -91,8 +91,7 @@ def _get_skyhub_data(url):
return
if response.status_code == 200:
return _parse_skyhub_response(response.text)
else:
_LOGGER.error("Invalid response from Sky Hub: %s", response)
_LOGGER.error("Invalid response from Sky Hub: %s", response)
def _parse_skyhub_response(data_str):
@@ -107,7 +107,7 @@ class TomatoDeviceScanner(DeviceScanner):
json.loads(value.replace("'", '"'))
return True
elif response.status_code == 401:
if response.status_code == 401:
# Authentication error
_LOGGER.exception((
"Failed to authenticate, "