--absolute asks for another form of time, not for one fewer fact

A never-heard node has no instant to print, so the timestamp language dropped
"never" back to the plain absent token and a contacts listing under --absolute
could no longer tell "we have not heard from it" from "this row has no heard
time". The absent word survives the switch; only the form of a real time changes.

Also drops a dead guard in the preferences writer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-09-08 04:07:27 -04:00
1 parent de0f60cbe0
commit 8d2a7b8281
3 files changed
+15 -6

No files matched your search

+1 -1
View File
@@ -125,7 +125,7 @@ class PreferencesTool(Tool):
if changes:
prefs.save()
if scripted and applied is not None and any(op[0] in ("set", "reset") for op in ops):
if scripted and any(op[0] in ("set", "reset") for op in ops):
blocks.append(_written(applied, prefs))
plural = "" if changes == 1 else "s"
+11 -4
View File
@@ -451,10 +451,17 @@ def _flag_cell(value: bool | None) -> str:
def _time(value: Any, *, absent: str) -> str:
"""Render a time in whichever language this run speaks (see :func:`when`)."""
if isinstance(value, datetime) or value is None:
return script.stamp(value) if _absolute() else script.age(value, absent=absent)
return normalise(value) # pragma: no cover - a row holding something else is a bug
"""Render a time in whichever language this run speaks (see :func:`when`).
``absent`` survives the switch to timestamps, because it is not a rendering choice:
``never`` says the event has not happened, and ``--absolute`` was asked for a different
*form* of time, not for one fewer fact.
"""
if not isinstance(value, datetime) and value is not None:
return normalise(value) # pragma: no cover - a row holding something else is a bug
if value is None:
return absent
return script.stamp(value) if _absolute() else script.age(value, absent=absent)
def _absolute() -> bool:
+3 -1
View File
@@ -269,10 +269,12 @@ def test_contacts_names_every_node_bare_and_ages_every_time(run) -> None: # noq
age = line.split()[2]
assert age in ("now", "never") or age[-1] in "mhdw"
# `--absolute` asks for a different *form* of time, not for one fewer fact, so
# `never` survives it: a node that has never been heard has no instant to print.
absolute = result_lines(run("--absolute", "contacts"))[1:]
for line in absolute:
stamp = line.split()[2]
assert stamp == "-" or stamp[:4].isdigit()
assert stamp in ("-", "never") or stamp[:4].isdigit()
def test_contacts_never_elides_a_key(run) -> None: # noqa: ANN001