oliver-zehentleitner / maity
clean-up: hub-wide: RFC 3339 parsing without the .replace(Z) workaround, in nine places; placements._stamp is views.ts
tsk-kfpz2m8we8f1 Open
From the clean-up audit tsk-hgnbapyw7hnh (findings A3-9, A9-18), read at 80647565. Line numbers are at that SHA; check them against current main first. Paths are under hub/src/maity_hub/.
What is wrong
Nine places parse an RFC 3339 time with datetime.fromisoformat(value.replace("Z", "+00:00")). The workaround was only needed before Python 3.11; the hub requires Python 3.12 or newer (hub/pyproject.toml:11), and fromisoformat accepts a trailing Z itself. clock.py has rfc3339() for writing but no parser, so each module writes its own.
Sites
forge.py:1002-1009_moment(:1007) andgithub_app.py:234-240_expiry(:238): the same parser twice.ktw.py:260,maintenance.py:49,notifications/preferences.py:227,placements.py:999,routes/ticker.py:237,ticker.py:689.routes/limit.py:42upper-cases the text first (text.upper().replace(...)); check why before folding it in (probably to accept a lower-casetorz), and keep that behaviour.placements.py:1144-1145_stampisviews.py:38-39tsunder another name (writing, not parsing).
Proposal
- Either add
clock.parse_rfc3339(value) -> datetime | None(None for a non-string or a parse error, as_momentdoes) and use it at all nine sites, or drop the.replaceand calldatetime.fromisoformatdirectly.forge._momentandgithub_app._expirybecome one call either way. - Replace
placements._stampwithviews.ts(orclock.rfc3339with a None check if importing views would make a cycle).
Effort and risk
- Effort S. Risk low: on 3.12,
fromisoformatgives the same result with or without the.replace. The forge and ticker tests cover the GitHub timestamps.
Order
forge.pyandgithub_app.pyare reworked by tsk-e77g3nhqqnex item 1 (one GitHub transport), andplacements.pyby tsk-j0vqtv3zhacw; rebase rather than conflict.
Open question
- One helper in
clock.py, or plaindatetime.fromisoformatat each site? The helper also gives one place for the "None on a bad value" rule that_moment,_expiryandroutes/ticker.py:237each write out.
Covered elsewhere
- None. Searched: rfc3339, fromisoformat. tsk-e77g3nhqqnex and tsk-j0vqtv3zhacw list A3-9 and A9-18 as left for this card.
Effort sum: S (1 point).
Notes
Maity Coder Claude 003 · Nov 13, 2026, 23:12 UTC
More sites from the clean-up audit (tsk-hgnbapyw7hnh, uncovered-files pass at 9dfd4b65):
routes/limit.py:42ticker.py:689;routes/ticker.py:237ktw.py:260
Related: tsk-jzkpfe8yfkgr item 1 is the formatting side ("RFC 3339 or null", about 25 copies;
not_listening_digest._stampusesisoformat). One PR could do both directions.