Removal of extraneous parenthesis (#33637)

This commit is contained in:
Franck Nijhof 2020-04-04 20:08:55 +02:00 committed by GitHub
parent 7d3c974747
commit 187b6525b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 59 additions and 80 deletions

View File

@ -217,16 +217,14 @@ async def async_get_conditions(
)
conditions.extend(
(
{
**template,
"condition": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for template in templates
)
{
**template,
"condition": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for template in templates
)
return conditions

View File

@ -226,16 +226,14 @@ async def async_get_triggers(hass, device_id):
)
triggers.extend(
(
{
**automation,
"platform": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for automation in templates
)
{
**automation,
"platform": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for automation in templates
)
return triggers

View File

@ -186,15 +186,13 @@ async def _async_get_automations(
for entry in entries:
automations.extend(
(
{
**template,
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": domain,
}
for template in automation_templates
)
{
**template,
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": domain,
}
for template in automation_templates
)
return automations

View File

@ -124,9 +124,7 @@ def get_last_state_changes(hass, number_of_states, entity_id):
start_time = dt_util.utcnow()
with session_scope(hass=hass) as session:
query = session.query(States).filter(
(States.last_changed == States.last_updated)
)
query = session.query(States).filter(States.last_changed == States.last_updated)
if entity_id is not None:
query = query.filter_by(entity_id=entity_id.lower())

View File

@ -66,7 +66,7 @@ OPERATION_MODES = {
"Dry": HVAC_MODE_DRY,
}
OPERATION_MODES_INV = dict((reversed(item) for item in OPERATION_MODES.items()))
OPERATION_MODES_INV = dict(reversed(item) for item in OPERATION_MODES.items())
PRESET_MODES = {
# Map DPT 201.100 HVAC operating modes to HA presets
@ -76,7 +76,7 @@ PRESET_MODES = {
"Comfort": PRESET_COMFORT,
}
PRESET_MODES_INV = dict((reversed(item) for item in PRESET_MODES.items()))
PRESET_MODES_INV = dict(reversed(item) for item in PRESET_MODES.items())
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{

View File

@ -46,9 +46,7 @@ SERVICE_TO_METHOD = {
async def async_setup(hass, config):
"""Set up the Kodi integration."""
if any(
((CONF_PLATFORM, DOMAIN) in cfg.items() for cfg in config.get(MP_DOMAIN, []))
):
if any((CONF_PLATFORM, DOMAIN) in cfg.items() for cfg in config.get(MP_DOMAIN, [])):
# Register the Kodi media_player services
async def async_service_handler(service):
"""Map services to methods on MediaPlayerDevice."""

View File

@ -335,11 +335,9 @@ class KonnectedView(HomeAssistantView):
payload = await request.json()
except json.decoder.JSONDecodeError:
_LOGGER.error(
(
"Your Konnected device software may be out of "
"date. Visit https://help.konnected.io for "
"updating instructions."
)
"Your Konnected device software may be out of "
"date. Visit https://help.konnected.io for "
"updating instructions."
)
device = data[CONF_DEVICES].get(device_id)
@ -389,11 +387,9 @@ class KonnectedView(HomeAssistantView):
request.query.get(CONF_ZONE) or PIN_TO_ZONE[request.query[CONF_PIN]]
)
zone = next(
(
switch
for switch in device[CONF_SWITCHES]
if switch[CONF_ZONE] == zone_num
)
switch
for switch in device[CONF_SWITCHES]
if switch[CONF_ZONE] == zone_num
)
except StopIteration:

View File

@ -201,13 +201,13 @@ class NextBusDepartureSensor(Entity):
messages = listify(results.get("message", []))
self._log_debug("Messages: %s", messages)
self._attributes["message"] = " -- ".join(
(message.get("text", "") for message in messages)
message.get("text", "") for message in messages
)
# List out all directions in the attributes
directions = listify(results.get("direction", []))
self._attributes["direction"] = ", ".join(
(direction.get("title", "") for direction in directions)
direction.get("title", "") for direction in directions
)
# Chain all predictions together

View File

@ -47,12 +47,12 @@ def get_time_until(departure_time=None):
return 0
delta = dt_util.utc_from_timestamp(int(departure_time)) - dt_util.now()
return round((delta.total_seconds() / 60))
return round(delta.total_seconds() / 60)
def get_delay_in_minutes(delay=0):
"""Get the delay in minutes from a delay in seconds."""
return round((int(delay) / 60))
return round(int(delay) / 60)
def get_ride_duration(departure_time, arrival_time, delay=0):
@ -60,7 +60,7 @@ def get_ride_duration(departure_time, arrival_time, delay=0):
duration = dt_util.utc_from_timestamp(
int(arrival_time)
) - dt_util.utc_from_timestamp(int(departure_time))
duration_time = int(round((duration.total_seconds() / 60)))
duration_time = int(round(duration.total_seconds() / 60))
return duration_time + get_delay_in_minutes(delay)

View File

@ -98,7 +98,7 @@ def _resize_image(image, opts):
new_width = old_width
scale = new_width / float(old_width)
new_height = int((float(old_height) * float(scale)))
new_height = int(float(old_height) * float(scale))
img = img.resize((new_width, new_height), Image.ANTIALIAS)
imgbuf = io.BytesIO()

View File

@ -21,14 +21,14 @@ def purge_old_data(instance, purge_days, repack):
with session_scope(session=instance.get_session()) as session:
deleted_rows = (
session.query(States)
.filter((States.last_updated < purge_before))
.filter(States.last_updated < purge_before)
.delete(synchronize_session=False)
)
_LOGGER.debug("Deleted %s states", deleted_rows)
deleted_rows = (
session.query(Events)
.filter((Events.time_fired < purge_before))
.filter(Events.time_fired < purge_before)
.delete(synchronize_session=False)
)
_LOGGER.debug("Deleted %s events", deleted_rows)

View File

@ -113,16 +113,14 @@ async def async_get_conditions(
)
conditions.extend(
(
{
**template,
"condition": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for template in templates
)
{
**template,
"condition": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for template in templates
)
return conditions

View File

@ -129,16 +129,14 @@ async def async_get_triggers(hass, device_id):
)
triggers.extend(
(
{
**automation,
"platform": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for automation in templates
)
{
**automation,
"platform": "device",
"device_id": device_id,
"entity_id": entry.entity_id,
"domain": DOMAIN,
}
for automation in templates
)
return triggers

View File

@ -176,7 +176,7 @@ class Monitor(threading.Thread):
value[2],
value[1],
)
self.data["temp"] = float(("%d.%d" % (value[0], value[2])))
self.data["temp"] = float("%d.%d" % (value[0], value[2]))
self.data["humid"] = value[1]
def terminate(self):

View File

@ -113,10 +113,7 @@ class TomatoDeviceScanner(DeviceScanner):
if response.status_code == 401:
# Authentication error
_LOGGER.exception(
(
"Failed to authenticate, "
"please check your username and password"
)
"Failed to authenticate, please check your username and password"
)
return False