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
+10 -3
View File
@@ -133,10 +133,17 @@ def shape_of(columns: tuple[str, ...]) -> Shape:
return OLD_SHAPE if MOVES not in columns and {"A", "G", OLD_SHAPE.goals_column}.intersection(columns) else SHAPE
def items(todo: str) -> list[Item] | None | Failure:
"""Each row of a todo.md's items table; None where todo.md holds no items table."""
@dataclasses.dataclass(frozen=True)
class NoItemsTable(Failure):
"""todo.md holds no items table, which is not an empty one: that reads as an empty list."""
def items(todo: str) -> list[Item] | Failure:
"""Each row of a todo.md's items table; a NoItemsTable where todo.md holds none."""
table = items_table(todo.splitlines())
if table is None or isinstance(table, Failure):
if table is None:
return NoItemsTable("todo.md holds no items table")
if isinstance(table, Failure):
return table
found = []
for row in table.rows: