Self-contained, skip-friendly lab starting points (#103)
Sync course wiki / sync-wiki (push) Successful in 5s
CI / check (push) Successful in 6s

Co-authored-by: claude <claude@jpaul.io>
Co-committed-by: claude <claude@jpaul.io>
This commit was merged in pull request #103.
This commit is contained in:
2026-06-23 18:24:36 -04:00
committed by Claude (agent)
parent 74f23534c0
commit 7f439212ac
85 changed files with 2724 additions and 0 deletions
@@ -0,0 +1,42 @@
"""Core task logic for the demo app.
Deliberately small and deliberately split across two files (this and cli.py) so that the
copy-paste workflow has more than one place to go wrong. This is the running example used in
Modules 1 and 2.
"""
from dataclasses import dataclass, field
@dataclass
class Task:
title: str
done: bool = False
@dataclass
class TaskList:
tasks: list[Task] = field(default_factory=list)
def add(self, title: str) -> Task:
task = Task(title=title)
self.tasks.append(task)
return task
def complete(self, index: int) -> None:
self.tasks[index].done = True
def remove(self, index: int) -> None:
del self.tasks[index]
def pending(self) -> list[Task]:
return [t for t in self.tasks if not t.done]
def render(self) -> str:
if not self.tasks:
return "(no tasks yet)"
lines = []
for i, task in enumerate(self.tasks):
box = "[x]" if task.done else "[ ]"
lines.append(f"{i}. {box} {task.title}")
return "\n".join(lines)