Trim comments and docstrings

This commit is contained in:
J. Nick Koston
2026-08-22 23:57:36 -05:00
parent 3100e9be21
commit 62c314bf57
2 changed files with 4 additions and 8 deletions
+2 -4
View File
@@ -555,10 +555,8 @@ def write_file_if_changed(path: Path, text: str) -> bool:
try:
src_content = path.read_text(encoding="utf-8")
except UnicodeDecodeError as err:
# A damaged existing file must be replaced, not abort the very
# regeneration that would fix it. Only decode failures recover:
# an OSError (permissions, I/O) may hide an intact file and
# propagates below like it always did.
# Replace a damaged file rather than abort the regeneration that
# fixes it; an OSError may hide an intact file, so it still raises
_LOGGER.warning("Replacing damaged file %s: %s", path, err)
with suppress(OSError):
path.unlink(missing_ok=True)
+2 -4
View File
@@ -256,8 +256,7 @@ class Test_write_file_if_changed:
def test_damaged_existing_file_is_replaced(
self, tmp_path: Path, caplog: pytest.LogCaptureFixture
):
"""A non-UTF-8 existing file is logged and overwritten; aborting
would block the very regeneration that fixes it."""
"""A non-UTF-8 existing file is logged and overwritten."""
dst = tmp_path / "generated.txt"
dst.write_bytes(b"\xff\xfe")
@@ -267,8 +266,7 @@ class Test_write_file_if_changed:
assert "Replacing damaged file" in caplog.text
def test_unreadable_existing_file_still_raises(self, tmp_path: Path):
"""An OSError on the comparison read may hide an intact file, so it
propagates as EsphomeError instead of unlinking."""
"""An OSError on the comparison read still raises EsphomeError."""
dst = tmp_path / "generated.txt"
dst.write_text("intact")