From 4620a54582ea83f1f6b9880adab72804ff178737 Mon Sep 17 00:00:00 2001 From: Sid <27780930+autinerd@users.noreply.github.com> Date: Fri, 19 Jul 2024 12:06:53 +0200 Subject: [PATCH] Bump Ruff to 0.5.3 (#122167) --- .pre-commit-config.yaml | 2 +- homeassistant/components/prometheus/__init__.py | 5 +---- homeassistant/components/roku/media_player.py | 3 +-- .../zwave_js/triggers/value_updated.py | 11 +++-------- pyproject.toml | 2 +- requirements_test_pre_commit.txt | 2 +- tests/components/unifiprotect/test_switch.py | 17 +++++++++-------- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f1766dc196..0e44d5ff402 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.2 + rev: v0.5.3 hooks: - id: ruff args: diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index 7c7cdd7d366..f7037a685a6 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -326,10 +326,7 @@ class PrometheusMetrics: return "".join( [ c - if c in string.ascii_letters - or c in string.digits - or c == "_" - or c == ":" + if c in string.ascii_letters + string.digits + "_:" else f"u{hex(ord(c))}" for c in metric ] diff --git a/homeassistant/components/roku/media_player.py b/homeassistant/components/roku/media_player.py index 881dda38f15..5b15253068e 100644 --- a/homeassistant/components/roku/media_player.py +++ b/homeassistant/components/roku/media_player.py @@ -149,8 +149,7 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity): return None if ( - self.coordinator.data.app.name == "Power Saver" - or self.coordinator.data.app.name == "Roku" + self.coordinator.data.app.name in {"Power Saver", "Roku"} or self.coordinator.data.app.screensaver ): return MediaPlayerState.IDLE diff --git a/homeassistant/components/zwave_js/triggers/value_updated.py b/homeassistant/components/zwave_js/triggers/value_updated.py index 4814eba0757..d8c5702ce5d 100644 --- a/homeassistant/components/zwave_js/triggers/value_updated.py +++ b/homeassistant/components/zwave_js/triggers/value_updated.py @@ -128,14 +128,9 @@ async def async_attach_trigger( (prev_value, prev_value_raw, from_value), (curr_value, curr_value_raw, to_value), ): - if ( - match != MATCH_ALL - and value_to_eval != match - and not ( - isinstance(match, list) - and (value_to_eval in match or raw_value_to_eval in match) - ) - and raw_value_to_eval != match + if match not in (MATCH_ALL, value_to_eval, raw_value_to_eval) and not ( + isinstance(match, list) + and (value_to_eval in match or raw_value_to_eval in match) ): return diff --git a/pyproject.toml b/pyproject.toml index 298f6a427da..6d3bdcab7e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -693,7 +693,7 @@ exclude_lines = [ ] [tool.ruff] -required-version = ">=0.5.2" +required-version = ">=0.5.3" [tool.ruff.lint] select = [ diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 80add9a50ee..3c4da0141cd 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -1,5 +1,5 @@ # Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit codespell==2.3.0 -ruff==0.5.2 +ruff==0.5.3 yamllint==1.35.1 diff --git a/tests/components/unifiprotect/test_switch.py b/tests/components/unifiprotect/test_switch.py index 6e5c83ef237..9e0e9efa0ce 100644 --- a/tests/components/unifiprotect/test_switch.py +++ b/tests/components/unifiprotect/test_switch.py @@ -35,15 +35,16 @@ CAMERA_SWITCHES_BASIC = [ for d in CAMERA_SWITCHES if ( not d.name.startswith("Detections:") - and d.name != "SSH enabled" - and d.name != "Color night vision" - and d.name != "Tracking: person" - and d.name != "HDR mode" + and d.name + not in {"SSH enabled", "Color night vision", "Tracking: person", "HDR mode"} ) - or d.name == "Detections: motion" - or d.name == "Detections: person" - or d.name == "Detections: vehicle" - or d.name == "Detections: animal" + or d.name + in { + "Detections: motion", + "Detections: person", + "Detections: vehicle", + "Detections: animal", + } ] CAMERA_SWITCHES_NO_EXTRA = [ d