refactor(api): trailing newlines + hoist acks.py parser imports to top-level

Self-review nits from the router-split commit:
- All four new files lacked a trailing newline (PEP 8 / POSIX).
- acks.py was lazily importing ParseResult999 / serialize_999 inside
  get_ack_endpoint. Hoist to module-level — there's no import cycle
  (acks.py does not import from cyclone.api), so the imports are safe
  to do once.

No behavior change. Targeted tests (test_acks + test_health + test_api_gets)
still pass 41/41.
This commit is contained in:
Tyler
2026-06-21 00:50:31 -06:00
parent a63ba5e88c
commit 1267a341e3
4 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -1 +1 @@
"""Resource-group routers. Imported and registered by ``cyclone.api``."""
"""Resource-group routers. Imported and registered by ``cyclone.api``."""
+3 -3
View File
@@ -17,6 +17,8 @@ from fastapi import APIRouter, HTTPException, Query, Request
from fastapi.responses import StreamingResponse
from cyclone.api_helpers import ndjson_stream_list, wants_ndjson
from cyclone.parsers.models_999 import ParseResult999
from cyclone.parsers.serialize_999 import serialize_999
from cyclone.store import store
router = APIRouter()
@@ -91,8 +93,6 @@ def get_ack_endpoint(ack_id: int) -> dict:
# the regenerated text to keep payloads small; detail does.)
if row.raw_json:
try:
from cyclone.parsers.models_999 import ParseResult999
from cyclone.parsers.serialize_999 import serialize_999
regenerated = ParseResult999.model_validate(row.raw_json)
icn = regenerated.envelope.control_number or "000000001"
body["raw_999_text"] = serialize_999(regenerated, interchange_control_number=icn)
@@ -101,4 +101,4 @@ def get_ack_endpoint(ack_id: int) -> dict:
body["raw_999_text"] = None
else:
body["raw_999_text"] = None
return body
return body
+1 -1
View File
@@ -14,4 +14,4 @@ router = APIRouter()
@router.get("/api/health")
def health() -> dict[str, str]:
return {"status": "ok", "version": __version__}
return {"status": "ok", "version": __version__}
+1 -1
View File
@@ -73,4 +73,4 @@ def get_ta1_ack_endpoint(ack_id: int) -> dict:
body = _ta1_to_ui(row)
body["raw_ta1_text"] = _serialize_ta1_from_row(row)
body["raw_json"] = row.raw_json
return body
return body