From cbec776ef1be0692dd57851584a348bb1dc916b7 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Fri, 1 May 2026 20:59:44 -0700 Subject: [PATCH] fix: restore ensure_ascii=False in utils jsonl helpers; remove dead _last_action from api.py --- app/api.py | 8 -------- app/utils.py | 4 ++-- tests/test_api.py | 2 -- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/api.py b/app/api.py index 3303bf2..c08c2e5 100644 --- a/app/api.py +++ b/app/api.py @@ -80,11 +80,6 @@ def _config_file() -> Path: return _ROOT / "config" / "label_tool.yaml" -def reset_last_action() -> None: - """Reset undo state — used by tests.""" - global _last_action - _last_action = None - def _queue_file() -> Path: return _DATA_DIR / "email_label_queue.jsonl" @@ -161,9 +156,6 @@ app.include_router(imitate_router, prefix="/api/imitate") from app.style import router as style_router app.include_router(style_router, prefix="/api/style") -# In-memory last-action store (single user, local tool — in-memory is fine) -_last_action: dict | None = None - class AccountTestRequest(BaseModel): account: dict diff --git a/app/utils.py b/app/utils.py index 4b40ddd..5dae97a 100644 --- a/app/utils.py +++ b/app/utils.py @@ -106,7 +106,7 @@ def read_jsonl(path: Path) -> list[dict]: def write_jsonl(path: Path, records: list[dict]) -> None: """Write records to a JSONL file, overwriting any existing content.""" path.parent.mkdir(parents=True, exist_ok=True) - content = "\n".join(json.dumps(r) for r in records) + content = "\n".join(json.dumps(r, ensure_ascii=False) for r in records) path.write_text(content + ("\n" if records else ""), encoding="utf-8") @@ -114,4 +114,4 @@ def append_jsonl(path: Path, record: dict) -> None: """Append a single record to a JSONL file.""" path.parent.mkdir(parents=True, exist_ok=True) with open(path, "a", encoding="utf-8") as fh: - fh.write(json.dumps(record) + "\n") + fh.write(json.dumps(record, ensure_ascii=False) + "\n") diff --git a/tests/test_api.py b/tests/test_api.py index 101a701..9d5c928 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -9,12 +9,10 @@ def reset_globals(tmp_path): from app import api from app.data import label as label_module api.set_data_dir(tmp_path) - api.reset_last_action() label_module.set_data_dir(tmp_path) label_module.set_config_dir(tmp_path) label_module.reset_last_action() yield - api.reset_last_action() label_module.reset_last_action()