Answer stability round 1: 0 🔴, 2 🟡; name the rename fix in the finished message and the changelog, read a bad newest mark as unknown, refuse a self-rename, share the release parser, test the strip

This commit is contained in:
2026-10-18 09:47:44 +02:00
parent 28a3f9c5e9
commit 1f0a046dd4
7 changed files with 41 additions and 19 deletions
+16 -7
View File
@@ -24,7 +24,8 @@ Standing = typing.Literal["next", "cut", "finished", "unplanned", "unknown"]
# todo.md's ## Details section, its body the first group.
DETAILS = re.compile(r"^## Details\n(.*?)(?=^## |\Z)", re.M | re.S)
# One line of todo.md's ## Renamed section, the release it renamed and the one it became.
RENAME = re.compile(r"- ([0-9]+\.[0-9]+\.[0-9]+) renamed to [0-9]+\.[0-9]+\.[0-9]+")
RELEASE = r"[0-9]+\.[0-9]+\.[0-9]+"
RENAME = re.compile(rf"- ({RELEASE}) renamed to ({RELEASE})")
# Each goal an item names, in its order, with how far the item moves it; None in OLD_SHAPE, whose Goals cell names no move.
Moves = tuple[tuple[str, int | None], ...]
@@ -205,9 +206,11 @@ def landed(cut: LastCut) -> int | Failure:
def named_releases(todos: list[str] | Failure) -> set[tuple[int, int, int]] | Failure:
"""Each release the todo.md texts, oldest first, file items under, leaving out one that a later text marks renamed, unless a text after that files items under it again; a text that does not parse names none."""
"""Each release the todo.md texts, oldest first, file items under, leaving out one that a later text marks renamed, unless a text after that files items under it again. A text whose items do not parse names none; the newest text's marks failing to parse fails the whole, since a release left unmarked would read as finished."""
if isinstance(todos, Failure):
return todos
if todos and isinstance(newest := renames(todos[-1]), Failure):
return newest
named: set[tuple[int, int, int]] = set()
for text in todos:
plan, marked = items(text), renames(text)
@@ -224,8 +227,9 @@ def renames(todo: str) -> set[tuple[int, int, int]] | Failure:
rename = RENAME.fullmatch(line.strip())
if rename is None:
return Failure(f"todo.md's ## Renamed section holds {line.strip()!r}, not a line such as `- 0.2.1 renamed to 0.3.0`")
major, minor, patch = (int(part) for part in rename.group(1).split("."))
marked.add((major, minor, patch))
if rename.group(1) == rename.group(2):
return Failure(f"todo.md's ## Renamed section renames {rename.group(1)} to itself; name the release it became")
marked.add(release_of(rename.group(1)))
return marked
@@ -318,8 +322,13 @@ def parse_row(row: str, table: Table) -> Item | Failure:
moves = shape.read_goals(named["ID"], named[shape.goals_column])
if isinstance(moves, Failure):
return moves
major, minor, patch = (int(part) for part in named["Release"].split("."))
return Item(int(named["ID"]), (major, minor, patch), named["Exempt"], named["Item"], scores, moves, blocked_by)
return Item(int(named["ID"]), release_of(named["Release"]), named["Exempt"], named["Item"], scores, moves, blocked_by)
def release_of(version: str) -> tuple[int, int, int]:
"""The release a RELEASE-shaped version names."""
major, minor, patch = (int(part) for part in version.split("."))
return major, minor, patch
def check_cells(row: str, named: dict[str, str]) -> Failure | None:
@@ -327,7 +336,7 @@ def check_cells(row: str, named: dict[str, str]) -> Failure | None:
id_, release, exempt, tagline = named["ID"], named["Release"], named["Exempt"], named["Item"]
if not re.fullmatch(r"[0-9]+", id_) or int(id_) < 1:
return Failure(f"the ID {id_!r} is not a positive whole number: {row}")
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", release):
if not re.fullmatch(RELEASE, release):
return Failure(f"item {id_}'s release {release!r} is not a semver version")
if exempt not in EXEMPTIONS:
return Failure(f"item {id_}'s Exempt {exempt!r} is not empty or one of {', '.join(EXEMPTIONS[1:])}")