Give todo_table.items one way to say a plan has no items table

This commit is contained in:
2026-10-22 00:32:30 +02:00
parent f429e256de
commit f0ece378c0
7 changed files with 38 additions and 18 deletions
+5 -3
View File
@@ -3,7 +3,7 @@ import pathlib
from larv_review.git import committed_since_release
from failure import Failure
from git_repo import file_at, top
from todo_table import Item, items, renames, version
from todo_table import Item, items, NoItemsTable, renames, version
def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], landed: bool, renamed: set[tuple[int, int, int]]) -> list[str] | Failure:
@@ -44,11 +44,13 @@ def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure:
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read todo.md: {failure}")
# While a chunk reshapes todo.md into one table, the default branch's todo.md has no items table.
planned = items(before) or []
planned = items(before)
if isinstance(planned, NoItemsTable):
planned = []
if isinstance(planned, Failure):
return Failure(f"{default}'s todo.md: {planned.reason}")
chunk = items(after)
if chunk is None:
if isinstance(chunk, NoItemsTable):
return Failure("the checkout's todo.md has no items table; rank_todo.py --help shows one")
if isinstance(chunk, Failure):
return Failure(f"the checkout's todo.md: {chunk.reason}")
+3 -2
View File
@@ -16,7 +16,7 @@ import comprehension_history
from larv_review.ruling import counted, ruling, split, votes
from failure import Failure
from test_env import isolated_env
from todo_table import Item, items
from todo_table import Item, items, NoItemsTable
from larv_review.scoring import means, under_floor
from larv_review.ruling_base import measured_commit
from larv_review.seats import score_line, scores, seats_file
@@ -260,7 +260,8 @@ class Base(unittest.TestCase):
class ScoringRunDue(unittest.TestCase):
def test_reads_each_rows_id_release_and_tagline(self):
self.assertEqual(items(todo("| 3 | 0.1.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |")), [item(3, (0, 1, 0))])
self.assertIsNone(items("# todo\n"))
self.assertEqual(items("# todo\n"), NoItemsTable("todo.md holds no items table"))
self.assertIsInstance(items("# todo\n"), Failure)
self.assertIsInstance(items(todo("| 0 | 0.1.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |")), Failure)
def test_is_due_for_an_item_naming_the_floor(self):