refactor: use __len__ for MailDebugRecorder, str() size estimate, clearer tests, fix unused import
Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/5d2918de-630e-4a66-8355-1b036c620b1c Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
aab60d6866
commit
eeb3fa5c66
@@ -4,7 +4,6 @@ Supports both POP3 and IMAP protocols with secure connections.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json as _json
|
||||
import poplib
|
||||
import re
|
||||
import smtplib
|
||||
@@ -198,7 +197,7 @@ class MailDebugRecorder:
|
||||
if data:
|
||||
entry["data"] = data
|
||||
try:
|
||||
entry_bytes = len(_json.dumps(entry, default=str))
|
||||
entry_bytes = len(str(entry))
|
||||
except Exception:
|
||||
entry_bytes = 256 # conservative fallback
|
||||
if (
|
||||
@@ -223,6 +222,9 @@ class MailDebugRecorder:
|
||||
def has_entries(self) -> bool:
|
||||
return bool(self._entries)
|
||||
|
||||
def __len__(self) -> int:
|
||||
return len(self._entries)
|
||||
|
||||
def as_details(self) -> Dict[str, Any]:
|
||||
"""Return the trace as a dict suitable for storage in error_details."""
|
||||
return {"trace": self._entries, "truncated": self._truncated}
|
||||
|
||||
Reference in New Issue
Block a user