diff --git a/homeassistant/components/binary_sensor/device_condition.py b/homeassistant/components/binary_sensor/device_condition.py index cb98ec90b5d681e21e488640c906a2ad41ea4727..e17869f6cfa6cc23b40d9dc9430485f435c29ef4 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 f4799828c688232e4151225e1166efea80c91527..e5e1f9061e6a4427b769b8483ffbcb08ab0a0474 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 a2dcd62db8cc35f43efcecc5c6eb5a1779f548b8..e9a65f7bedd0f783d5d400e900c7725e732d80a3 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 7540740a73707cad91464855af52a4ba62d35054..6fc68b2833e1c48e472c99c37eae13d306988a16 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 919a20d0e4c7568f7c4b5c7e497e32c3f76f0593..e6da946c81c38b7e8984b5d78faa5b943f3cef08 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 1f2d3cb5cd09568a1860c90ae95a06b0f76f910c..9470c8bb2c824fa9deda968b69e7bb287ae64a56 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 e5185ff03bc96ea849ed903b121ba8f57aa6a798..8df6f7cead62aaa9fce2dd5f8356bd5c1e505b36 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 5909804ebd1ac8a12d0592b5f9a8795330f8025d..2b5da2a97fac65553d64639025251329a1e23099 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 dfa43c359529dce4f7d07e337654d7d41387ec36..c6dd7b963ff31c4dfdccc5232e0f4ab14a049070 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 893fadfe178a81d9dab33bf5ca1f3ee8fc5173c2..a2912ef0dbea14f8ce7184184b8504ea00dfe38e 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 b4b1f612fac368830836e87991e14a00e863f919..0c247c961267819ebf97a8f4c3455357d46e5b7a 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 bb0348eb6a73edd12f71107d7ce054250ded869f..3c4337c1dba8dc64ce33acb5d58eb7a398e4629e 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 1af8a5e4ab08d98a047ca8d46400d8a22c93652b..57c32da97e9aae15550a065fb059845ef446a4fa 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 9bd02aec7c4f9b31c3a4dd1971d2dad5b0a35ba8..d976e6e9408cd5ea1bc3417d911c61edb8759bfe 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 5a5f1b1985b123ad7eda652cab87747779b387d4..35db0671772d48dc72d3100c84657fb56f6451d6 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