From 435a88636a2a13c777ed7e831b198ade3c7a77f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 30 Apr 2020 22:37:58 +0300 Subject: [PATCH] Address new issues flagged by flake8 3.8.0a2 (#34964) --- homeassistant/components/discord/notify.py | 1 + homeassistant/components/group/light.py | 2 +- .../components/streamlabswater/__init__.py | 4 +++- homeassistant/components/wunderlist/__init__.py | 2 +- homeassistant/components/zha/core/helpers.py | 2 +- script/scaffold/docs.py | 2 +- .../geo_json_events/test_geo_location.py | 4 ++-- tests/components/huawei_lte/test_config_flow.py | 2 +- .../minecraft_server/test_config_flow.py | 4 ++-- tests/components/ssdp/test_init.py | 4 ++-- tests/components/system_log/test_init.py | 2 +- .../test/alarm_control_panel.py | 4 ++-- .../custom_components/test/cover.py | 16 ++++++++-------- .../custom_components/test/lock.py | 4 ++-- 14 files changed, 28 insertions(+), 25 deletions(-) diff --git a/homeassistant/components/discord/notify.py b/homeassistant/components/discord/notify.py index fb36a60eecc..11f83d80179 100644 --- a/homeassistant/components/discord/notify.py +++ b/homeassistant/components/discord/notify.py @@ -65,6 +65,7 @@ class DiscordNotificationService(BaseNotificationService): images.append(image) else: _LOGGER.warning("Image not found: %s", image) + # pylint: disable=unused-variable @discord_bot.event async def on_ready(): diff --git a/homeassistant/components/group/light.py b/homeassistant/components/group/light.py index eb043177eba..56408f410b8 100644 --- a/homeassistant/components/group/light.py +++ b/homeassistant/components/group/light.py @@ -326,7 +326,7 @@ def _mean_int(*args): def _mean_tuple(*args): """Return the mean values along the columns of the supplied values.""" - return tuple(sum(l) / len(l) for l in zip(*args)) + return tuple(sum(x) / len(x) for x in zip(*args)) def _reduce_attribute( diff --git a/homeassistant/components/streamlabswater/__init__.py b/homeassistant/components/streamlabswater/__init__.py index 836bc9b4183..336e92358ee 100644 --- a/homeassistant/components/streamlabswater/__init__.py +++ b/homeassistant/components/streamlabswater/__init__.py @@ -59,7 +59,9 @@ def setup(hass, config): "Streamlabs Water Monitor auto-detected location_id=%s", location_id ) else: - location = next((l for l in locations if location_id == l["locationId"]), None) + location = next( + (loc for loc in locations if location_id == loc["locationId"]), None + ) if location is None: _LOGGER.error("Supplied location_id is invalid") return False diff --git a/homeassistant/components/wunderlist/__init__.py b/homeassistant/components/wunderlist/__init__.py index 4d9ff6e2235..954088e4b21 100644 --- a/homeassistant/components/wunderlist/__init__.py +++ b/homeassistant/components/wunderlist/__init__.py @@ -85,7 +85,7 @@ class Wunderlist: def _list_by_name(self, name): """Return a list ID by name.""" lists = self._client.get_lists() - tmp = [l for l in lists if l["title"] == name] + tmp = [lst for lst in lists if lst["title"] == name] if tmp: return tmp[0]["id"] return None diff --git a/homeassistant/components/zha/core/helpers.py b/homeassistant/components/zha/core/helpers.py index 4441ac90717..bb8a202e789 100644 --- a/homeassistant/components/zha/core/helpers.py +++ b/homeassistant/components/zha/core/helpers.py @@ -101,7 +101,7 @@ def mean_int(*args): def mean_tuple(*args): """Return the mean values along the columns of the supplied values.""" - return tuple(sum(l) / len(l) for l in zip(*args)) + return tuple(sum(x) / len(x) for x in zip(*args)) def reduce_attribute( diff --git a/script/scaffold/docs.py b/script/scaffold/docs.py index 8186b857e80..f4416a7b7e8 100644 --- a/script/scaffold/docs.py +++ b/script/scaffold/docs.py @@ -69,7 +69,7 @@ def print_relevant_docs(template: str, info: Info) -> None: print() print( - f"The next step is to look at the files and deal with all areas marked as TODO." + "The next step is to look at the files and deal with all areas marked as TODO." ) if "extra" in data: diff --git a/tests/components/geo_json_events/test_geo_location.py b/tests/components/geo_json_events/test_geo_location.py index e10125f84ac..6b7535a8c85 100644 --- a/tests/components/geo_json_events/test_geo_location.py +++ b/tests/components/geo_json_events/test_geo_location.py @@ -189,8 +189,8 @@ async def test_setup_race_condition(hass): # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 15.5, (-31.0, 150.0)) - delete_signal = f"geo_json_events_delete_1234" - update_signal = f"geo_json_events_update_1234" + delete_signal = "geo_json_events_delete_1234" + update_signal = "geo_json_events_update_1234" # Patching 'utcnow' to gain more control over the timed update. utcnow = dt_util.utcnow() diff --git a/tests/components/huawei_lte/test_config_flow.py b/tests/components/huawei_lte/test_config_flow.py index 86de1ad8bd1..ae1e8184727 100644 --- a/tests/components/huawei_lte/test_config_flow.py +++ b/tests/components/huawei_lte/test_config_flow.py @@ -138,7 +138,7 @@ async def test_success(hass, login_requests_mock): login_requests_mock.request( ANY, f"{FIXTURE_USER_INPUT[CONF_URL]}api/user/login", - text=f"OK", + text="OK", ) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=FIXTURE_USER_INPUT diff --git a/tests/components/minecraft_server/test_config_flow.py b/tests/components/minecraft_server/test_config_flow.py index bc49ed08109..7db6dc33b5a 100644 --- a/tests/components/minecraft_server/test_config_flow.py +++ b/tests/components/minecraft_server/test_config_flow.py @@ -68,12 +68,12 @@ USER_INPUT_IPV6 = { USER_INPUT_PORT_TOO_SMALL = { CONF_NAME: DEFAULT_NAME, - CONF_HOST: f"mc.dummyserver.com:1023", + CONF_HOST: "mc.dummyserver.com:1023", } USER_INPUT_PORT_TOO_LARGE = { CONF_NAME: DEFAULT_NAME, - CONF_HOST: f"mc.dummyserver.com:65536", + CONF_HOST: "mc.dummyserver.com:65536", } SRV_RECORDS = asyncio.Future() diff --git a/tests/components/ssdp/test_init.py b/tests/components/ssdp/test_init.py index 62b7c2bbde2..b6499af5601 100644 --- a/tests/components/ssdp/test_init.py +++ b/tests/components/ssdp/test_init.py @@ -61,7 +61,7 @@ async def test_scan_not_all_present(hass, aioclient_mock): """Test match fails if some specified attributes are not present.""" aioclient_mock.get( "http://1.1.1.1", - text=f""" + text=""" Paulus @@ -96,7 +96,7 @@ async def test_scan_not_all_match(hass, aioclient_mock): """Test match fails if some specified attribute values differ.""" aioclient_mock.get( "http://1.1.1.1", - text=f""" + text=""" Paulus diff --git a/tests/components/system_log/test_init.py b/tests/components/system_log/test_init.py index 92f0ed9fd16..6408b1625f5 100644 --- a/tests/components/system_log/test_init.py +++ b/tests/components/system_log/test_init.py @@ -139,7 +139,7 @@ async def test_remove_older_logs(hass, hass_client): def log_msg(nr=2): """Log an error at same line.""" - _LOGGER.error(f"error message %s", nr) + _LOGGER.error("error message %s", nr) async def test_dedup_logs(hass, hass_client): diff --git a/tests/testing_config/custom_components/test/alarm_control_panel.py b/tests/testing_config/custom_components/test/alarm_control_panel.py index 5edb1ca2f70..6535f5aa1f5 100644 --- a/tests/testing_config/custom_components/test/alarm_control_panel.py +++ b/tests/testing_config/custom_components/test/alarm_control_panel.py @@ -32,12 +32,12 @@ def init(empty=False): if empty else { "arm_code": MockAlarm( - name=f"Alarm arm code", + name="Alarm arm code", code_arm_required=True, unique_id="unique_arm_code", ), "no_arm_code": MockAlarm( - name=f"Alarm no arm code", + name="Alarm no arm code", code_arm_required=False, unique_id="unique_no_arm_code", ), diff --git a/tests/testing_config/custom_components/test/cover.py b/tests/testing_config/custom_components/test/cover.py index f7b0dae15ee..095489ce7b4 100644 --- a/tests/testing_config/custom_components/test/cover.py +++ b/tests/testing_config/custom_components/test/cover.py @@ -29,29 +29,29 @@ def init(empty=False): if empty else [ MockCover( - name=f"Simple cover", + name="Simple cover", is_on=True, - unique_id=f"unique_cover", + unique_id="unique_cover", supports_tilt=False, ), MockCover( - name=f"Set position cover", + name="Set position cover", is_on=True, - unique_id=f"unique_set_pos_cover", + unique_id="unique_set_pos_cover", current_cover_position=50, supports_tilt=False, ), MockCover( - name=f"Set tilt position cover", + name="Set tilt position cover", is_on=True, - unique_id=f"unique_set_pos_tilt_cover", + unique_id="unique_set_pos_tilt_cover", current_cover_tilt_position=50, supports_tilt=True, ), MockCover( - name=f"Tilt cover", + name="Tilt cover", is_on=True, - unique_id=f"unique_tilt_cover", + unique_id="unique_tilt_cover", supports_tilt=True, ), ] diff --git a/tests/testing_config/custom_components/test/lock.py b/tests/testing_config/custom_components/test/lock.py index 4894f00fd75..a6ce9e102d5 100644 --- a/tests/testing_config/custom_components/test/lock.py +++ b/tests/testing_config/custom_components/test/lock.py @@ -19,13 +19,13 @@ def init(empty=False): if empty else { "support_open": MockLock( - name=f"Support open Lock", + name="Support open Lock", is_locked=True, supported_features=SUPPORT_OPEN, unique_id="unique_support_open", ), "no_support_open": MockLock( - name=f"No support open Lock", + name="No support open Lock", is_locked=True, supported_features=0, unique_id="unique_no_support_open",