Functional Weave
Code in Rust

todo.list@1.1.0

impl/python/toggle_all_mode.py

386 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from typing import Sequence

from .todo_item import Todo  ← from todo.item ^1.0.0 · built alongside by fune
from .todo_list_types import ToggleAllMode


def toggle_all_mode(todos: Sequence[Todo]) -> ToggleAllMode:
    """What toggle_all would do: complete while any todo is open, reopen once none is, none when empty."""
    if len(todos) == 0:
        return "none"
    return "complete" if any(not t.done for t in todos) else "reopen"