Skip to main content

Typed Note Service

Challenge on lesson: Checkpoint: A Typed Application Slice

Define TypedDict NoteDict(id: int, text: str), a @runtime_checkable Protocol NoteStore with add(note_id: int, text: str) -> None and get(note_id: int) -> str | None, class MemoryNotes implementing both, and function save_note(store: NoteStore, note: NoteDict) -> bool that raises ValueError when note['text'] is empty/whitespace, otherwise stores and returns True.

Difficulty: intermediate

Back to lesson: Checkpoint: A Typed Application Slice