From 9d6c77e8c2e9671a632a55fdab07bcb8db8b0a2e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 22 Aug 2026 23:57:52 -0500 Subject: [PATCH] Trim comments --- esphome/writer.py | 3 +-- tests/unit_tests/test_writer.py | 13 ++++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/esphome/writer.py b/esphome/writer.py index fbe36699e9..c08e4148bd 100644 --- a/esphome/writer.py +++ b/esphome/writer.py @@ -341,8 +341,7 @@ def copy_src_tree(): existing.get("config_hash") != config_hash or existing.get("esphome_version") != __version__ ): - # Valid JSON that is not an object (truncated or - # hand-edited) is stale like every other damage case + # Non-object JSON is stale like every other damage case sources_changed = True except (json.JSONDecodeError, OSError): sources_changed = True diff --git a/tests/unit_tests/test_writer.py b/tests/unit_tests/test_writer.py index 239d9551ac..38bef1f79b 100644 --- a/tests/unit_tests/test_writer.py +++ b/tests/unit_tests/test_writer.py @@ -2072,8 +2072,7 @@ def test_copy_src_tree_detects_config_hash_change( ) ) - # Create both existing build_info sources so the staleness decision - # reaches the JSON comparison instead of the missing-file branch + # Both sources must exist to reach the JSON comparison branch build_info_h_path = esphome_core_path / "build_info_data.h" build_info_h_path.write_text("// old build_info_data.h") (esphome_core_path / "build_info_data.cpp").write_text("// old") @@ -2138,8 +2137,7 @@ def test_copy_src_tree_detects_version_change( ) ) - # Create both existing build_info sources so the staleness decision - # reaches the JSON comparison instead of the missing-file branch + # Both sources must exist to reach the JSON comparison branch build_info_h_path = esphome_core_path / "build_info_data.h" build_info_h_path.write_text("// old build_info_data.h") (esphome_core_path / "build_info_data.cpp").write_text("// old") @@ -2190,8 +2188,7 @@ def test_copy_src_tree_handles_invalid_build_info_json( build_info_json_path = build_path / "build_info.json" build_info_json_path.write_text("invalid json {{{") - # Create both existing build_info sources so the staleness decision - # reaches the JSON comparison instead of the missing-file branch + # Both sources must exist to reach the JSON comparison branch build_info_h_path = esphome_core_path / "build_info_data.h" build_info_h_path.write_text("// old build_info_data.h") (esphome_core_path / "build_info_data.cpp").write_text("// old") @@ -2238,12 +2235,10 @@ def test_copy_src_tree_handles_non_dict_build_info_json( build_path = tmp_path / "build" build_path.mkdir() - # Valid JSON that is not an object: no .get, must read as stale build_info_json_path = build_path / "build_info.json" build_info_json_path.write_text("[]") - # Create both existing build_info sources so the staleness decision - # reaches the JSON comparison instead of the missing-file branch + # Both sources must exist to reach the JSON comparison branch build_info_h_path = esphome_core_path / "build_info_data.h" build_info_h_path.write_text("// old build_info_data.h") (esphome_core_path / "build_info_data.cpp").write_text("// old")