diff --git a/bin/todo_item/edits.py b/bin/todo_item/edits.py index 728e8fc9..802bec79 100644 --- a/bin/todo_item/edits.py +++ b/bin/todo_item/edits.py @@ -1,9 +1,9 @@ """The text edits behind todo-item: filing an item in todo.md, removing a finished one, and adding a bullet to CHANGELOG.md. Each returns new text; ranking.rank then orders the table and details and writes the derived cells.""" import re +from release_plan.todo_table import cells, DETAILS, items_table, Table from failure import Failure from release_plan.ranking import stated -from release_plan.todo_table import cells, DETAILS, items_table, Table # A line that would end the item's detail, or open another one, inside ## Details. HEADING = re.compile(r"^#{1,3} ", re.M) diff --git a/bin/todo_item/main.py b/bin/todo_item/main.py index 1930ff3f..2d5527ea 100644 --- a/bin/todo_item/main.py +++ b/bin/todo_item/main.py @@ -23,10 +23,10 @@ import pathlib import sys import typing +from todo_item.edits import added, finished, with_bullet +from release_plan.todo_table import BLOCKED_BY, MOVES from failure import Failure from release_plan import ranking -from release_plan.todo_table import BLOCKED_BY, MOVES -from todo_item.edits import added, finished, with_bullet # Each score flag, as --l or --L, and the column it fills. LETTERS = ("L", "E", "I", "S") @@ -95,11 +95,12 @@ def finish(args: argparse.Namespace, folder: pathlib.Path) -> str | Failure: ranked = ranking.rank(text, *texts[1:]) if isinstance(ranked, Failure): return ranked - news = None + news: str | None = None if args.changelog is not None: - news = with_bullet(changelog.read_text(encoding="utf-8") if changelog.exists() else "", args.changelog) - if isinstance(news, Failure): - return news + bulleted = with_bullet(changelog.read_text(encoding="utf-8") if changelog.exists() else "", args.changelog) + if isinstance(bulleted, Failure): + return bulleted + news = bulleted if unwritten := ranking.write(todo, ranked.text): return unwritten if news is not None and (unwritten := ranking.write(changelog, news)): diff --git a/bin/todo_item/test_todo_item.py b/bin/todo_item/test_todo_item.py index 7cafb0c3..05a49f2f 100644 --- a/bin/todo_item/test_todo_item.py +++ b/bin/todo_item/test_todo_item.py @@ -7,9 +7,9 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent)) -from release_plan import ranking from release_plan.test_ranking import DECISIONS, README, TODO from todo_item import main +from release_plan import ranking ADD = ["add", "--release", "0.1.0", "--l", "1", "--e", "1", "--i", "1", "--s", "1", "--moves", "1 by 9", "Count the `a | b` runs."] ROW = "| 6 | 0.1.0 | | | **Count the `a \\| b` runs.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 |"