mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Flake8 and Pylint fixes
This commit is contained in:
parent
0ac34aaa52
commit
60b427accc
@ -50,7 +50,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
continue
|
continue
|
||||||
dev.append(UberSensor('time', timeandpriceest, product_id, product))
|
dev.append(UberSensor('time', timeandpriceest, product_id, product))
|
||||||
if product.get('price_details') is not None:
|
if product.get('price_details') is not None:
|
||||||
dev.append(UberSensor('price', timeandpriceest, product_id, product))
|
dev.append(UberSensor('price', timeandpriceest,
|
||||||
|
product_id, product))
|
||||||
add_devices(dev)
|
add_devices(dev)
|
||||||
|
|
||||||
|
|
||||||
@ -81,8 +82,8 @@ class UberSensor(Entity):
|
|||||||
statekey = 'low_estimate'
|
statekey = 'low_estimate'
|
||||||
self._state = int(price_details.get(statekey, 0))
|
self._state = int(price_details.get(statekey, 0))
|
||||||
else:
|
else:
|
||||||
self._unit_of_measurement = 'N/A'
|
self._unit_of_measurement = 'N/A'
|
||||||
self._state = int(0)
|
self._state = int(0)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -108,9 +109,9 @@ class UberSensor(Entity):
|
|||||||
distance_key = 'Trip distance (in miles)'
|
distance_key = 'Trip distance (in miles)'
|
||||||
distance_val = self._product.get('distance', 'N/A')
|
distance_val = self._product.get('distance', 'N/A')
|
||||||
else:
|
else:
|
||||||
distance_key = 'Trip distance (in {}s)'.format(price_details[
|
distance_key = 'Trip distance (in {}s)'.format(price_details[
|
||||||
'distance_unit'])
|
'distance_unit'])
|
||||||
distance_val = self._product.get('distance')
|
distance_val = self._product.get('distance')
|
||||||
time_estimate = self._product.get('time_estimate_seconds', 'N/A')
|
time_estimate = self._product.get('time_estimate_seconds', 'N/A')
|
||||||
params = {
|
params = {
|
||||||
'Product ID': self._product['product_id'],
|
'Product ID': self._product['product_id'],
|
||||||
@ -124,20 +125,20 @@ class UberSensor(Entity):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if price_details is not None:
|
if price_details is not None:
|
||||||
params['Minimum price'] = price_details['minimum'],
|
params['Minimum price'] = price_details['minimum'],
|
||||||
params['Cost per minute'] = price_details['cost_per_minute'],
|
params['Cost per minute'] = price_details['cost_per_minute'],
|
||||||
params['Distance units'] = price_details['distance_unit'],
|
params['Distance units'] = price_details['distance_unit'],
|
||||||
params['Cancellation fee'] = price_details['cancellation_fee'],
|
params['Cancellation fee'] = price_details['cancellation_fee'],
|
||||||
params['Cost per distance unit'] = price_details['cost_per_distance'],
|
params['Cost per distance'] = price_details['cost_per_distance'],
|
||||||
params['Base price'] = price_details['base'],
|
params['Base price'] = price_details['base'],
|
||||||
params['Price estimate'] = price_details.get('estimate', 'N/A'),
|
params['Price estimate'] = price_details.get('estimate', 'N/A'),
|
||||||
params['Price currency code'] = price_details.get('currency_code'),
|
params['Price currency code'] = price_details.get('currency_code'),
|
||||||
params['High price estimate'] = price_details.get('high_estimate',
|
params['High price estimate'] = price_details.get('high_estimate',
|
||||||
'N/A'),
|
'N/A'),
|
||||||
params['Low price estimate'] = price_details.get('low_estimate',
|
params['Low price estimate'] = price_details.get('low_estimate',
|
||||||
'N/A'),
|
'N/A'),
|
||||||
params['Surge multiplier'] = price_details.get('surge_multiplier',
|
params['Surge multiplier'] = price_details.get('surge_multiplier',
|
||||||
'N/A')
|
'N/A')
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
@ -157,10 +158,10 @@ class UberSensor(Entity):
|
|||||||
elif self._sensortype == "price":
|
elif self._sensortype == "price":
|
||||||
price_details = self._product.get('price_details')
|
price_details = self._product.get('price_details')
|
||||||
if price_details is not None:
|
if price_details is not None:
|
||||||
min_price = price_details.get('minimum')
|
min_price = price_details.get('minimum')
|
||||||
self._state = int(price_details.get('low_estimate', min_price))
|
self._state = int(price_details.get('low_estimate', min_price))
|
||||||
else:
|
else:
|
||||||
self._state = int(0)
|
self._state = int(0)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
@ -210,14 +211,14 @@ class UberEstimate(object):
|
|||||||
product["duration"] = price.get('duration', '0')
|
product["duration"] = price.get('duration', '0')
|
||||||
product["distance"] = price.get('distance', '0')
|
product["distance"] = price.get('distance', '0')
|
||||||
if price_details is not None:
|
if price_details is not None:
|
||||||
price_details["estimate"] = price.get('estimate',
|
price_details["estimate"] = price.get('estimate',
|
||||||
'0')
|
'0')
|
||||||
price_details["high_estimate"] = price.get('high_estimate',
|
price_details["high_estimate"] = price.get('high_estimate',
|
||||||
'0')
|
'0')
|
||||||
price_details["low_estimate"] = price.get('low_estimate',
|
price_details["low_estimate"] = price.get('low_estimate',
|
||||||
'0')
|
'0')
|
||||||
price_details["surge_multiplier"] = price.get('surge_multiplier',
|
surge_multiplier = price.get('surge_multiplier', '0')
|
||||||
'0')
|
price_details["surge_multiplier"] = surge_multiplier
|
||||||
|
|
||||||
estimate_response = client.get_pickup_time_estimates(
|
estimate_response = client.get_pickup_time_estimates(
|
||||||
self.start_latitude, self.start_longitude)
|
self.start_latitude, self.start_longitude)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user