From 9b4b607a205445062843a1797b55ea18f5be794c Mon Sep 17 00:00:00 2001 From: Mark Eaton Date: Wed, 17 Sep 2025 19:10:49 -0400 Subject: [PATCH] refactor: replace print with string concatenation and convert "\n" to newlines in JSON output Co-authored-by: aider (o3) --- scripts/jsonl_pretty_print.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/jsonl_pretty_print.py b/scripts/jsonl_pretty_print.py index d8332ed..214b88d 100644 --- a/scripts/jsonl_pretty_print.py +++ b/scripts/jsonl_pretty_print.py @@ -50,9 +50,12 @@ def pretty_print_jsonl(path: Path, indent: int) -> None: obj = json.loads(line) except json.JSONDecodeError as exc: sys.exit(f"JSON decode error on line {idx}: {exc}") # fail fast - # Dump the pretty JSON followed by a newline separator - print(json.dumps(obj, indent=indent, ensure_ascii=False, sort_keys=True)) - print() # blank line between records for readability + # Build pretty JSON string, convert literal "\n" sequences to real newlines, + # and emit a blank line between records for readability. + pretty = json.dumps(obj, indent=indent, ensure_ascii=False, sort_keys=True) + pretty = pretty.replace("\\n", "\n") + sys.stdout.write(pretty) + sys.stdout.write("\n\n") def main() -> None: