[ci] Enable the ruff rule requiring explicit encoding on text file I/O (#17897)

This commit is contained in:
J. Nick Koston
2026-07-29 13:44:39 -04:00
committed by GitHub
parent 306d200b02
commit ca1f89e500
11 changed files with 23 additions and 14 deletions
+1 -1
View File
@@ -194,7 +194,7 @@ def cmd_update(args: argparse.Namespace) -> int:
def cmd_har_only(args: argparse.Namespace) -> int:
Path(args.har).write_text(run_waterfall(TARGET_MODULE))
Path(args.har).write_text(run_waterfall(TARGET_MODULE), encoding="utf-8")
print(f"Wrote waterfall HAR to {args.har}")
return 0
+1 -1
View File
@@ -269,7 +269,7 @@ def main() -> int:
if args.output_build_dir and build_dir:
build_dir_path = Path(args.output_build_dir)
build_dir_path.parent.mkdir(parents=True, exist_ok=True)
build_dir_path.write_text(build_dir)
build_dir_path.write_text(build_dir, encoding="utf-8")
print(f"Wrote build directory to {args.output_build_dir}", file=sys.stderr)
# Run detailed analysis if build directory available
+1 -1
View File
@@ -84,7 +84,7 @@ def _read_codspeed_version(cmake_path: Path) -> str:
"""Extract CODSPEED_VERSION from core/CMakeLists.txt."""
if not cmake_path.exists():
return "0.0.0"
for line in cmake_path.read_text().splitlines():
for line in cmake_path.read_text(encoding="utf-8").splitlines():
if line.startswith("set(CODSPEED_VERSION"):
return line.split()[1].rstrip(")")
return "0.0.0"
+2 -2
View File
@@ -367,7 +367,7 @@ def run_esphome_test(
output_file = build_dir / f"{component}.{test_name}.{platform_with_version}.yaml"
# Copy base file and substitute component test file reference
base_content = base_file.read_text()
base_content = base_file.read_text(encoding="utf-8")
# Get relative path from build dir to test file
repo_root = Path(__file__).parent.parent
component_test_ref = f"../../{test_file.relative_to(repo_root / 'tests')}"
@@ -524,7 +524,7 @@ def run_grouped_test(
# Create test file that includes merged config
output_file = build_dir / f"test_{group_name}.{platform_with_version}.yaml"
base_content = base_file.read_text()
base_content = base_file.read_text(encoding="utf-8")
merged_ref = merged_config_file.name
output_content = base_content.replace("$component_test_file", merged_ref)
output_file.write_text(output_content)