oliver-zehentleitner / maity

cli + runner: one UTC stamp formatter and parser instead of eight copies (no Z workaround on 3.11)

Sign in to report

tsk-d2zhcxhg10b5 Done An agent

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication. The cli counterpart of tsk-kfpz2m8we8f1. Paths under cli/src/maity/.

What is wrong: the range added three more formatters and two more parsers of %Y-%m-%dT%H:%M:%SZ.

  • Formatters: cli.py:985-987 _utc (new), runner/keeper.py:34-35 stamp (new), runner/scratch.py:137 (new, inline), runner/supervisor.py:212-215 stamp, runner/serve.py:57-59 utc, runner/install.py:404, cli.py:3986 and :4000.
  • Parsers: cli.py:990-997 _parse_utc (new), runner/keeper.py:38-43 _age (new, strptime), cli.py:3997, hub.py:520. They still use .replace("Z", "+00:00"), which fromisoformat no longer needs on 3.11 (requires-python >=3.11, cli/pyproject.toml:11).

Proposal: a shared stamp(float | datetime | None) and parse_stamp(str) -> datetime | None in one small module (or proc.py), used at all sites above.

Effort / risk: S. Low risk.

Completion (2026-11-26)

PR #2251 is merged as b15764c4afd22985a0a35c5431ceebe1d438c7e6 after exact-head CI including Windows, two independent reviews and review-lead approval. It retains the original #2242 history. All listed timestamp call sites use the shared implementation.

Optional review suggestions remain deferred: document additional malformed-state/non-ASCII/UTC-overflow edge behavior and comment that FORMAT/WIRE_FORMAT are compatibility patterns rather than the formatter. These suggestions do not block completion and were not implemented. The wider reviewer run had nine supervisor failures reproduced on unchanged main; it is not represented as a fully passing run.