fix(exception): NG1 fixed - 4 INTERNAL_OPTIONAL_RETURN violations migrated to Result[T]

This commit is contained in:
ed
2026-06-24 17:24:55 -04:00
parent b3c569ff4f
commit ee4287ae4d
3 changed files with 32 additions and 15 deletions
+7 -3
View File
@@ -40,10 +40,14 @@ def now_ts() -> str:
return datetime.datetime.now().strftime(TS_FMT)
def parse_ts(s: str) -> Optional[datetime.datetime]:
r = parse_ts_result(s)
return r.data if r.ok else None
def parse_ts_result(s: str) -> Result[datetime.datetime]:
try:
return datetime.datetime.strptime(s, TS_FMT)
except (ValueError, TypeError):
return None
return Result(data=datetime.datetime.strptime(s, TS_FMT))
except (ValueError, TypeError) as e:
return Result(data=None, errors=[ErrorInfo(kind=ErrorKind.INVALID_INPUT, message=f"Invalid timestamp {s!r}: {e}", source="project_manager.parse_ts_result", original=e)])
# ── entry serialisation ──────────────────────────────────────────────────────
def entry_to_str(entry: Metadata) -> str: