From d4e3603a19ac40571aed029a521e2be8b4c6f2ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 20 Aug 2026 15:46:39 -0500 Subject: [PATCH] Drop the dead name injection and pass board_mcu lazily --- esphome/arduino/library.py | 6 ++++-- tests/unit_tests/test_arduino_library.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/esphome/arduino/library.py b/esphome/arduino/library.py index d673b5fd73..75ce906b77 100644 --- a/esphome/arduino/library.py +++ b/esphome/arduino/library.py @@ -142,7 +142,7 @@ def _bundled_library(framework_path: Path, name: str) -> ArduinoLibrary: else: manifest = lib_dir / "library.properties" data = parse_library_properties(manifest) if manifest.is_file() else {} - return _library_info(name, lib_dir, {"name": name, **data}) + return _library_info(name, lib_dir, data) def resolve_libraries( @@ -219,7 +219,9 @@ def resolve_libraries( bundled.append(_bundled_library(framework_path, name)) def _emit(component: ConvertedLibrary) -> None: - apply_extra_script(component, board_mcu=board_mcu, pio_platform=pio_platform) + apply_extra_script( + component, board_mcu=lambda: board_mcu, pio_platform=pio_platform + ) converted.append( _library_info( component.get_require_name(), component.source_dir, component.data diff --git a/tests/unit_tests/test_arduino_library.py b/tests/unit_tests/test_arduino_library.py index 912038a20c..f8c0994c0c 100644 --- a/tests/unit_tests/test_arduino_library.py +++ b/tests/unit_tests/test_arduino_library.py @@ -214,9 +214,11 @@ def test_resolve_libraries_external_and_bundled_deps(tmp_path: Path) -> None: cache_key="arduino8266", ) - mock_extra.assert_called_once_with( - converted, board_mcu="esp8266", pio_platform="espressif8266" - ) + mock_extra.assert_called_once() + assert mock_extra.call_args.args == (converted,) + assert mock_extra.call_args.kwargs["pio_platform"] == "espressif8266" + # board_mcu is passed lazily, as the shared helper requires + assert mock_extra.call_args.kwargs["board_mcu"]() == "esp8266" assert [lib.name for lib in libs] == [ "Wire", "esp32async__ESPAsyncWebServer",