mirror of
https://github.com/esphome/esphome.git
synced 2026-10-03 09:46:03 +00:00
[core] Shrink apply_to_core to what upload/logs actually read
apply_to_core was over-populating: it restored friendly_name, loaded_integrations, and loaded_platforms even though every consumer of those three lives inside a component validator (esp32_camera, esp32, deep_sleep, zigbee, lvgl, zephyr_mcumgr), and the whole point of the fast path is to skip validation. Drop them. CORE.__init__ already leaves all three at safe defaults (None / empty set) for any incidental reader. What's left is exactly what upload/logs walk: - CORE.name (api.client.run_logs, firmware_bin path, mDNS) - CORE.build_path (firmware_bin / partition_table_bin / bootloader_bin) - CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] (module dispatch, .is_esp32 etc) - CORE.data[KEY_CORE][KEY_TARGET_FRAMEWORK] (.is_arduino, firmware_bin branch) Method body shrinks from 9 statements to 4; setdefault + two conditional inserts collapse into one dict literal; the function-local import moves to module top. Drift surface drops from 7 paired fields to 4. The wizard-only-sidecar None case is gated once at the load_compiled_config boundary so apply_to_core no longer has to defend against it.
This commit is contained in:
@@ -114,12 +114,18 @@ def test_load_compiled_config_happy_path(fresh_cache_files: Path) -> None:
|
||||
assert config[CONF_API]["encryption"]["key"] == "6dGhpcyBpcyBhIHRlc3Q="
|
||||
assert config["ota"][0]["password"] == "secret"
|
||||
|
||||
# apply_to_core ran as part of the orchestration.
|
||||
# apply_to_core populated exactly what upload/logs read off CORE.
|
||||
assert CORE.name == "lite_test"
|
||||
assert CORE.build_path == Path("/build/lite_test")
|
||||
assert CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] == "esp32"
|
||||
assert CORE.data[KEY_CORE][KEY_TARGET_FRAMEWORK] == "arduino"
|
||||
assert "api" in CORE.loaded_integrations
|
||||
|
||||
# The validator-only attributes are deliberately left at their
|
||||
# CORE.__init__ defaults. The fast path skips validation, so
|
||||
# nothing reads these.
|
||||
assert CORE.loaded_integrations == set()
|
||||
assert CORE.loaded_platforms == set()
|
||||
assert CORE.friendly_name is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user