From b7c105125e0da72288df948a8bda5306c170cd77 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 15 Nov 2025 10:13:43 -0600 Subject: [PATCH] proper codegen --- esphome/cpp_generator.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index 4f64b29f80f..5a8685dd0a4 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -764,9 +764,7 @@ def _try_deduplicate_lambda(lambda_expr: LambdaExpression) -> str | None: # Store the declaration to be added later (after all variable declarations) # We can't add it immediately because it might reference variables not yet declared - if _KEY_LAMBDA_DEDUP_DECLARATIONS not in CORE.data: - CORE.data[_KEY_LAMBDA_DEDUP_DECLARATIONS] = [] - CORE.data[_KEY_LAMBDA_DEDUP_DECLARATIONS].append(func_declaration) + CORE.data.setdefault(_KEY_LAMBDA_DEDUP_DECLARATIONS, []).append(func_declaration) # Store in cache lambda_cache[lambda_key] = func_name