From 0c29d28358e4b8452c9bbba0e199eb2c27ddc87d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 20:42:04 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../adaptive_lighting/color_and_brightness.py | 12 ++++-------- custom_components/adaptive_lighting/switch.py | 2 +- tests/test_switch.py | 7 ++----- webapp/color_and_brightness.py | 12 ++++-------- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/custom_components/adaptive_lighting/color_and_brightness.py b/custom_components/adaptive_lighting/color_and_brightness.py index 52386bf71..215a9a70d 100644 --- a/custom_components/adaptive_lighting/color_and_brightness.py +++ b/custom_components/adaptive_lighting/color_and_brightness.py @@ -64,12 +64,10 @@ def sunrise(self, dt: datetime.date) -> datetime.datetime: ) + self.sunrise_offset if self.min_sunrise_time is not None: min_sunrise = self._replace_time(dt, self.min_sunrise_time) - if min_sunrise > sunrise: - sunrise = min_sunrise + sunrise = max(min_sunrise, sunrise) if self.max_sunrise_time is not None: max_sunrise = self._replace_time(dt, self.max_sunrise_time) - if max_sunrise < sunrise: - sunrise = max_sunrise + sunrise = min(max_sunrise, sunrise) return sunrise def sunset(self, dt: datetime.date) -> datetime.datetime: @@ -81,12 +79,10 @@ def sunset(self, dt: datetime.date) -> datetime.datetime: ) + self.sunset_offset if self.min_sunset_time is not None: min_sunset = self._replace_time(dt, self.min_sunset_time) - if min_sunset > sunset: - sunset = min_sunset + sunset = max(min_sunset, sunset) if self.max_sunset_time is not None: max_sunset = self._replace_time(dt, self.max_sunset_time) - if max_sunset < sunset: - sunset = max_sunset + sunset = min(max_sunset, sunset) return sunset def _replace_time( diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 893e75658..29955d0ae 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -2552,7 +2552,7 @@ def _off_to_on_state_event_is_from_turn_on( and id_off_to_on == turn_on_event.context.id ) - async def just_turned_off( # noqa: PLR0911, PLR0912 + async def just_turned_off( # noqa: PLR0911 self, entity_id: str, ) -> bool: diff --git a/tests/test_switch.py b/tests/test_switch.py index e582a0319..9a15d5b0b 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -2112,11 +2112,8 @@ async def test_light_group( assert events[1].context.id == "testing" e1 = events[2].data["service_data"][ATTR_ENTITY_ID] e2 = events[3].data["service_data"][ATTR_ENTITY_ID] - assert ( - e1 == "light.light_4" - and e2 == "light.light_5" - or e1 == "light.light_5" - and e2 == "light.light_4" + assert (e1 == "light.light_4" and e2 == "light.light_5") or ( + e1 == "light.light_5" and e2 == "light.light_4" ) assert ":lght:" in events[2].context.id assert ":lght:" in events[3].context.id diff --git a/webapp/color_and_brightness.py b/webapp/color_and_brightness.py index ba804df35..b632ba8ef 100644 --- a/webapp/color_and_brightness.py +++ b/webapp/color_and_brightness.py @@ -64,12 +64,10 @@ def sunrise(self, dt: datetime.date) -> datetime.datetime: ) + self.sunrise_offset if self.min_sunrise_time is not None: min_sunrise = self._replace_time(dt, self.min_sunrise_time) - if min_sunrise > sunrise: - sunrise = min_sunrise + sunrise = max(min_sunrise, sunrise) if self.max_sunrise_time is not None: max_sunrise = self._replace_time(dt, self.max_sunrise_time) - if max_sunrise < sunrise: - sunrise = max_sunrise + sunrise = min(max_sunrise, sunrise) return sunrise def sunset(self, dt: datetime.date) -> datetime.datetime: @@ -81,12 +79,10 @@ def sunset(self, dt: datetime.date) -> datetime.datetime: ) + self.sunset_offset if self.min_sunset_time is not None: min_sunset = self._replace_time(dt, self.min_sunset_time) - if min_sunset > sunset: - sunset = min_sunset + sunset = max(min_sunset, sunset) if self.max_sunset_time is not None: max_sunset = self._replace_time(dt, self.max_sunset_time) - if max_sunset < sunset: - sunset = max_sunset + sunset = min(max_sunset, sunset) return sunset def _replace_time(