From 636bd7a797256d45453c5949b8d5ec8b523aaddd Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Mon, 6 Apr 2026 14:28:51 +0000 Subject: [PATCH] refactor(sensor): replace redundant pass-through lambdas with direct references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PLW0108: Three lambdas were simple pass-throughs that added no value: lambda data: aggregate_level_data(data) → aggregate_level_data lambda: lifecycle_calculator.get_lifecycle_state() → lifecycle_calculator.get_lifecycle_state Affected files: sensor/calculators/rolling_hour.py (line 115) sensor/helpers.py (line 139) sensor/value_getters.py (line 220) Impact: No behaviour change. Linter now passes with zero warnings. --- .../tibber_prices/sensor/calculators/rolling_hour.py | 2 +- custom_components/tibber_prices/sensor/helpers.py | 2 +- custom_components/tibber_prices/sensor/value_getters.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/tibber_prices/sensor/calculators/rolling_hour.py b/custom_components/tibber_prices/sensor/calculators/rolling_hour.py index 10ed65a..6e26078 100644 --- a/custom_components/tibber_prices/sensor/calculators/rolling_hour.py +++ b/custom_components/tibber_prices/sensor/calculators/rolling_hour.py @@ -112,7 +112,7 @@ class TibberPricesRollingHourCalculator(TibberPricesBaseCalculator): # Map other value types to aggregation functions aggregators = { - "level": lambda data: aggregate_level_data(data), + "level": aggregate_level_data, "rating": lambda data: aggregate_rating_data(data, threshold_low, threshold_high), } diff --git a/custom_components/tibber_prices/sensor/helpers.py b/custom_components/tibber_prices/sensor/helpers.py index 6488a23..b06dca9 100644 --- a/custom_components/tibber_prices/sensor/helpers.py +++ b/custom_components/tibber_prices/sensor/helpers.py @@ -136,7 +136,7 @@ def aggregate_window_data( # Map value types to aggregation functions aggregators: dict[str, Callable] = { "price": lambda data: aggregate_average_data(data, config_entry)[0], # Use only average from tuple - "level": lambda data: aggregate_level_data(data), + "level": aggregate_level_data, "rating": lambda data: aggregate_rating_data(data, threshold_low, threshold_high), } diff --git a/custom_components/tibber_prices/sensor/value_getters.py b/custom_components/tibber_prices/sensor/value_getters.py index f7d3625..4375bc8 100644 --- a/custom_components/tibber_prices/sensor/value_getters.py +++ b/custom_components/tibber_prices/sensor/value_getters.py @@ -217,7 +217,7 @@ def get_value_getter_mapping( # noqa: PLR0913 - needs all calculators as parame # Diagnostic sensors "data_timestamp": get_data_timestamp, # Data lifecycle status sensor - "data_lifecycle_status": lambda: lifecycle_calculator.get_lifecycle_state(), + "data_lifecycle_status": lifecycle_calculator.get_lifecycle_state, # Home metadata sensors (via MetadataCalculator) "home_type": lambda: metadata_calculator.get_home_metadata_value("type"), "home_size": lambda: metadata_calculator.get_home_metadata_value("size"),