Format todo list for display. Args: todo_list: List from compute_todo_list() test_by_lib: Dict mapping lib_name -> list of test infos (optional) limit: Maximum number of items to show verbose: Show detailed dependency information Returns: List of for
(
todo_list: list[dict],
test_by_lib: dict[str, list[dict]] | None = None,
limit: int | None = None,
verbose: bool = False,
)
| 448 | |
| 449 | |
| 450 | def format_todo_list( |
| 451 | todo_list: list[dict], |
| 452 | test_by_lib: dict[str, list[dict]] | None = None, |
| 453 | limit: int | None = None, |
| 454 | verbose: bool = False, |
| 455 | ) -> list[str]: |
| 456 | """Format todo list for display. |
| 457 | |
| 458 | Args: |
| 459 | todo_list: List from compute_todo_list() |
| 460 | test_by_lib: Dict mapping lib_name -> list of test infos (optional) |
| 461 | limit: Maximum number of items to show |
| 462 | verbose: Show detailed dependency information |
| 463 | |
| 464 | Returns: |
| 465 | List of formatted lines |
| 466 | """ |
| 467 | lines = [] |
| 468 | |
| 469 | if limit: |
| 470 | todo_list = todo_list[:limit] |
| 471 | |
| 472 | for item in todo_list: |
| 473 | name = item["name"] |
| 474 | score = item["score"] |
| 475 | total_deps = item["total_deps"] |
| 476 | rev_count = item["reverse_deps_count"] |
| 477 | |
| 478 | done_mark = "[x]" if item["up_to_date"] else "[ ]" |
| 479 | |
| 480 | if score == -1: |
| 481 | score_str = "no deps" |
| 482 | else: |
| 483 | score_str = f"{score}/{total_deps} deps" |
| 484 | |
| 485 | rev_str = f"{rev_count} dependents" if rev_count else "" |
| 486 | |
| 487 | parts = ["-", done_mark, f"[{score_str}]", f"`{name}`"] |
| 488 | if rev_str: |
| 489 | parts.append(f"({rev_str})") |
| 490 | |
| 491 | line = " ".join(parts) + _format_meta_suffix(item) |
| 492 | lines.append(line) |
| 493 | |
| 494 | # Show hard_deps: |
| 495 | # - Normal mode: only show if lib is up-to-date but hard_deps are not |
| 496 | # - Verbose mode: always show all hard_deps with their status |
| 497 | hard_deps_status = item.get("hard_deps_status", {}) |
| 498 | if verbose and hard_deps_status: |
| 499 | for hd in sorted(hard_deps_status.keys()): |
| 500 | hd_mark = "[x]" if hard_deps_status[hd] else "[ ]" |
| 501 | lines.append(f" - {hd_mark} {hd} (hard_dep)") |
| 502 | elif item["up_to_date"]: |
| 503 | for hd, ok in sorted(hard_deps_status.items()): |
| 504 | if not ok: |
| 505 | lines.append(f" - [ ] {hd} (hard_dep)") |
| 506 | |
| 507 | # Show corresponding tests if exist |
no test coverage detected