From 7a7baafcb32a453588b95a0897f332eec2e185a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:25:19 -0700 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#748) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.284](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.282...v0.0.284) * Ruff fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bas Nijholt --- .pre-commit-config.yaml | 2 +- custom_components/adaptive_lighting/hass_utils.py | 7 +++---- custom_components/adaptive_lighting/switch.py | 11 +++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 31fdf86c..e7b8b253 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.282 + rev: v0.0.284 hooks: - id: ruff args: ["--fix"] diff --git a/custom_components/adaptive_lighting/hass_utils.py b/custom_components/adaptive_lighting/hass_utils.py index ba5bb8b0..cc3257ce 100644 --- a/custom_components/adaptive_lighting/hass_utils.py +++ b/custom_components/adaptive_lighting/hass_utils.py @@ -51,12 +51,11 @@ def setup_service_call_interceptor( # Convert data back to read-only call.data = ReadOnlyDict(data) - except Exception as e: # noqa: BLE001 + except Exception: # Blindly catch all exceptions to avoid breaking light.turn_on - _LOGGER.error( - "Error for call '%s' in service_func_proxy: '%s'", + _LOGGER.exception( + "Error for call '%s' in service_func_proxy", call.data, - e, ) # Call original service handler with processed data await existing_service.job.target(call) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index ff951d15..7e910525 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -681,7 +681,7 @@ def _convert_attributes(attributes: dict[str, Any]) -> dict[str, Any]: if rgb is not None: attributes[ATTR_RGB_COLOR] = rgb - _LOGGER.debug(f"Converted {attributes} to rgb {rgb}") + _LOGGER.debug("Converted attributes %s to rgb %s", attributes, rgb) else: _LOGGER.debug("No suitable color conversion found for %s", attributes) @@ -1041,11 +1041,10 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): try: # HACK: this is a private method in `Entity` which can change super()._call_on_remove_callbacks() - except AttributeError as err: - _LOGGER.error( - "%s: Caught AttributeError in `_call_on_remove_callbacks`: %s", + except AttributeError: + _LOGGER.exception( + "%s: Caught AttributeError in `_call_on_remove_callbacks`", self._name, - err, ) def _remove_interval_listener(self) -> None: @@ -1816,7 +1815,7 @@ class AdaptiveLightingManager: single_switch_with_multiple_lights and switch_without_multi_light_intercept ): _LOGGER.warning( - "Single switch with multiple lights targeted, but" + "Single switch with multiple lights targeted (%s), but" " `multi_light_intercept: true` is not set, so skipping intercept" " for all lights.", switch_to_eids,