Answer product-owner round 1: 0 🔴, 1 🟡; list the known columns when one is unknown, and name each blocker ID the ranking drops

This commit is contained in:
2026-10-15 23:25:02 +02:00
parent 28a8741a10
commit a012f38617
2 changed files with 13 additions and 6 deletions
+7 -3
View File
@@ -91,6 +91,8 @@ class Scoring:
class Ranked:
text: str
under_bar: list[str]
# Each blocker ID the ranking dropped because the table no longer holds it, which a typo would look like too.
dropped: list[str]
def main(argv: list[str]) -> int:
@@ -116,7 +118,7 @@ def main(argv: list[str]) -> int:
unwritten = write(todo, ranked.text)
if unwritten:
return fail(unwritten)
for line in ranked.under_bar:
for line in ranked.dropped + ranked.under_bar:
print(f"{todo}: {line}", file=sys.stderr)
return 1 if ranked.under_bar else 0
@@ -188,7 +190,9 @@ def rank(text: str, readme: str, decisions: str) -> Ranked | Failure:
if isinstance(ranked, Failure):
return ranked
under_bar = [under_the_bar(item, value, scoring.bar, items) for item, value in scored if not item.exempt and round(value, 1) < scoring.bar]
return Ranked(ranked, under_bar)
held = {item.id for item in items}
dropped = [f"item {item.id}: dropped {', '.join(map(str, gone))} from its {BLOCKED_BY}; the table no longer holds it" for item in items if (gone := sorted(set(item.blocked_by) - held))]
return Ranked(ranked, under_bar, dropped)
def blocked_through(id_: int, items: list[Item]) -> set[int]:
@@ -252,7 +256,7 @@ def read_items(lines: list[str], scoring: Scoring) -> tuple[list[Item], Table] |
return Failure("todo.md's items table has no C column; add one after S, and score each item's C from 1 to 10 per rank_todo.py --help")
# Ranking writes COLUMNS, so it would drop a column it does not know.
if unknown := [column for column in table.columns if column not in COLUMNS]:
return Failure(f"todo.md's items table has the column {', '.join(unknown)}, which this rank_todo.py does not know; move this machine to the release that added it")
return Failure(f"todo.md's items table has the column {', '.join(unknown)}, which this rank_todo.py does not know; its columns are {', '.join(COLUMNS)}. Rename it, or move this machine to the release that added it")
if misplaced := outside_items(lines, table):
return misplaced
items = []