From 187b6525b4abff10b67c16bce7e9048996c964b8 Mon Sep 17 00:00:00 2001
From: Franck Nijhof <git@frenck.dev>
Date: Sat, 4 Apr 2020 20:08:55 +0200
Subject: [PATCH] Removal of extraneous parenthesis (#33637)

---
 .../binary_sensor/device_condition.py          | 18 ++++++++----------
 .../components/binary_sensor/device_trigger.py | 18 ++++++++----------
 .../device_automation/toggle_entity.py         | 16 +++++++---------
 homeassistant/components/history/__init__.py   |  4 +---
 homeassistant/components/knx/climate.py        |  4 ++--
 homeassistant/components/kodi/__init__.py      |  4 +---
 homeassistant/components/konnected/__init__.py | 16 ++++++----------
 homeassistant/components/nextbus/sensor.py     |  4 ++--
 homeassistant/components/nmbs/sensor.py        |  6 +++---
 homeassistant/components/proxy/camera.py       |  2 +-
 homeassistant/components/recorder/purge.py     |  4 ++--
 .../components/sensor/device_condition.py      | 18 ++++++++----------
 .../components/sensor/device_trigger.py        | 18 ++++++++----------
 homeassistant/components/skybeacon/sensor.py   |  2 +-
 .../components/tomato/device_tracker.py        |  5 +----
 15 files changed, 59 insertions(+), 80 deletions(-)

diff --git a/homeassistant/components/binary_sensor/device_condition.py b/homeassistant/components/binary_sensor/device_condition.py
index cb98ec90b5d..e17869f6cfa 100644
--- a/homeassistant/components/binary_sensor/device_condition.py
+++ b/homeassistant/components/binary_sensor/device_condition.py
@@ -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
diff --git a/homeassistant/components/binary_sensor/device_trigger.py b/homeassistant/components/binary_sensor/device_trigger.py
index f4799828c68..e5e1f9061e6 100644
--- a/homeassistant/components/binary_sensor/device_trigger.py
+++ b/homeassistant/components/binary_sensor/device_trigger.py
@@ -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
diff --git a/homeassistant/components/device_automation/toggle_entity.py b/homeassistant/components/device_automation/toggle_entity.py
index a2dcd62db8c..e9a65f7bedd 100644
--- a/homeassistant/components/device_automation/toggle_entity.py
+++ b/homeassistant/components/device_automation/toggle_entity.py
@@ -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
diff --git a/homeassistant/components/history/__init__.py b/homeassistant/components/history/__init__.py
index 7540740a737..6fc68b2833e 100644
--- a/homeassistant/components/history/__init__.py
+++ b/homeassistant/components/history/__init__.py
@@ -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())
diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py
index 919a20d0e4c..e6da946c81c 100644
--- a/homeassistant/components/knx/climate.py
+++ b/homeassistant/components/knx/climate.py
@@ -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(
     {
diff --git a/homeassistant/components/kodi/__init__.py b/homeassistant/components/kodi/__init__.py
index 1f2d3cb5cd0..9470c8bb2c8 100644
--- a/homeassistant/components/kodi/__init__.py
+++ b/homeassistant/components/kodi/__init__.py
@@ -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."""
diff --git a/homeassistant/components/konnected/__init__.py b/homeassistant/components/konnected/__init__.py
index e5185ff03bc..8df6f7cead6 100644
--- a/homeassistant/components/konnected/__init__.py
+++ b/homeassistant/components/konnected/__init__.py
@@ -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:
diff --git a/homeassistant/components/nextbus/sensor.py b/homeassistant/components/nextbus/sensor.py
index 5909804ebd1..2b5da2a97fa 100644
--- a/homeassistant/components/nextbus/sensor.py
+++ b/homeassistant/components/nextbus/sensor.py
@@ -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
diff --git a/homeassistant/components/nmbs/sensor.py b/homeassistant/components/nmbs/sensor.py
index dfa43c35952..c6dd7b963ff 100644
--- a/homeassistant/components/nmbs/sensor.py
+++ b/homeassistant/components/nmbs/sensor.py
@@ -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)
 
 
diff --git a/homeassistant/components/proxy/camera.py b/homeassistant/components/proxy/camera.py
index 893fadfe178..a2912ef0dbe 100644
--- a/homeassistant/components/proxy/camera.py
+++ b/homeassistant/components/proxy/camera.py
@@ -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()
diff --git a/homeassistant/components/recorder/purge.py b/homeassistant/components/recorder/purge.py
index b4b1f612fac..0c247c96126 100644
--- a/homeassistant/components/recorder/purge.py
+++ b/homeassistant/components/recorder/purge.py
@@ -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)
diff --git a/homeassistant/components/sensor/device_condition.py b/homeassistant/components/sensor/device_condition.py
index bb0348eb6a7..3c4337c1dba 100644
--- a/homeassistant/components/sensor/device_condition.py
+++ b/homeassistant/components/sensor/device_condition.py
@@ -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
diff --git a/homeassistant/components/sensor/device_trigger.py b/homeassistant/components/sensor/device_trigger.py
index 1af8a5e4ab0..57c32da97e9 100644
--- a/homeassistant/components/sensor/device_trigger.py
+++ b/homeassistant/components/sensor/device_trigger.py
@@ -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
diff --git a/homeassistant/components/skybeacon/sensor.py b/homeassistant/components/skybeacon/sensor.py
index 9bd02aec7c4..d976e6e9408 100644
--- a/homeassistant/components/skybeacon/sensor.py
+++ b/homeassistant/components/skybeacon/sensor.py
@@ -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):
diff --git a/homeassistant/components/tomato/device_tracker.py b/homeassistant/components/tomato/device_tracker.py
index 5a5f1b1985b..35db0671772 100644
--- a/homeassistant/components/tomato/device_tracker.py
+++ b/homeassistant/components/tomato/device_tracker.py
@@ -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
 
-- 
GitLab