Skip to content

Commit e3d17e1

Browse files
committed
Add json reporting functions.
1 parent af6731f commit e3d17e1

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
JSON reporting utilities (optional).
3+
"""
4+
5+
from __future__ import annotations
6+
7+
import json
8+
from typing import Any, Dict
9+
10+
from ..observability import to_dict
11+
12+
13+
def to_json_dict(report) -> Dict[str, Any]:
14+
"""Convert AnalysisReport to a JSON-serializable dict."""
15+
return to_dict(report)
16+
17+
18+
def write_json(report, path: str) -> None:
19+
"""Write report to a file as pretty JSON."""
20+
with open(path, "w", encoding="utf-8") as f:
21+
json.dump(to_json_dict(report), f, indent=2)
22+
json.dump(to_json_dict(report), f, indent=2)

0 commit comments

Comments
 (0)