diff --git a/tests/skill/understand/test_merge_batch_graphs.py b/tests/skill/understand/test_merge_batch_graphs.py index 7239bfe63..bf0b453c2 100644 --- a/tests/skill/understand/test_merge_batch_graphs.py +++ b/tests/skill/understand/test_merge_batch_graphs.py @@ -983,7 +983,7 @@ def _run_merge(self) -> tuple[int, str, dict]: capture_output=True, text=True, ) out_path = self.intermediate / "assembled-graph.json" - assembled = _j.loads(out_path.read_text()) if out_path.exists() else {} + assembled = _j.loads(out_path.read_text(encoding="utf-8")) if out_path.exists() else {} return result.returncode, result.stderr, assembled def test_two_parts_of_one_logical_batch_merge(self) -> None: @@ -1102,7 +1102,7 @@ def _run_merge(self) -> tuple[int, str, dict]: capture_output=True, text=True, ) out_path = self.intermediate / "assembled-graph.json" - assembled = _j.loads(out_path.read_text()) if out_path.exists() else {} + assembled = _j.loads(out_path.read_text(encoding="utf-8")) if out_path.exists() else {} return result.returncode, result.stderr, assembled def test_fused_filename_emits_stderr_warning(self) -> None: diff --git a/understand-anything-plugin/skills/understand-domain/extract-domain-context.py b/understand-anything-plugin/skills/understand-domain/extract-domain-context.py index 061206a65..22568f565 100644 --- a/understand-anything-plugin/skills/understand-domain/extract-domain-context.py +++ b/understand-anything-plugin/skills/understand-domain/extract-domain-context.py @@ -123,7 +123,7 @@ def parse_gitignore(project_root: Path) -> list[re.Pattern[str]]: if not gitignore.exists(): return patterns - for line in gitignore.read_text(errors="replace").splitlines(): + for line in gitignore.read_text(encoding="utf-8", errors="replace").splitlines(): line = line.strip() if not line or line.startswith("#"): continue @@ -208,7 +208,7 @@ def detect_entry_points(root: Path, file_paths: list[str]) -> list[dict[str, Any continue full_path = root / rel_path try: - content = full_path.read_text(errors="replace") + content = full_path.read_text(encoding="utf-8", errors="replace") except (OSError, UnicodeDecodeError): continue @@ -267,7 +267,7 @@ def priority_score(path: str) -> int: for rel_path in sorted_paths[:MAX_SAMPLED_FILES]: full_path = root / rel_path try: - content = full_path.read_text(errors="replace") + content = full_path.read_text(encoding="utf-8", errors="replace") except (OSError, UnicodeDecodeError): continue @@ -312,7 +312,7 @@ def extract_metadata(root: Path) -> dict[str, Any]: if not filepath.exists(): continue try: - content = filepath.read_text(errors="replace") + content = filepath.read_text(encoding="utf-8", errors="replace") except (OSError, UnicodeDecodeError): continue @@ -415,7 +415,7 @@ def main() -> None: context = _truncate_to_fit(context) output = json.dumps(context, indent=2) - output_path.write_text(output) + output_path.write_text(output, encoding="utf-8") size_kb = len(output.encode()) / 1024 print(f" Wrote {output_path} ({size_kb:.0f} KB)", file=sys.stderr)