mirror of
https://github.com/esphome/esphome.git
synced 2026-08-24 07:06:20 +00:00
Trim comments and docstrings
This commit is contained in:
+2
-4
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user