Skip to content

A hook returns a string - #23

Merged
nigelgilbert merged 10 commits into
chore/pythonic-meditations-1from
feature/hooks-return-str
Nov 22, 2026
Merged

nigelgilbert merged 10 commits into
chore/pythonic-meditations-1from
feature/hooks-return-str

Conversation

@nigelgilbert

@nigelgilbert nigelgilbert commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

A hook now returns a string. Returning None, or nothing, used to mean "leave it as it was". Now it fails like any other hook failure:

on_cleaned in voice.py: TypeError: on_cleaned returned NoneType, not str

To change nothing, a text hook does return t. The five hooks, their signatures and their order are the same, and "" still stops.

What changed

  • sidecar/src/kiku_sidecar/lifecycle.py: call accepts only a str, fire assigns the result directly, and hook_message returns the first message it gets. Hook is Callable[[Any], str].
  • Tests: the hooks in test_server.py and test_lifecycle.py return strings, and a new test covers a text hook with no return.
  • Docs: docs/hooks.md and sidecar/README.md drop the None rows, and six recipes get an explicit return.
  • Examples: every hook in examples/ returns a string on every path.

For existing hook files

A hook that ends without a return now stops the dictation with the TypeError above. Add return t.

Review

One review raised 7 candidates and 4 were kept and fixed: the offline.py recipe now returns the label, the type and the message, and three wording fixes say an on_done return is not used. The details are in docs/factory-report-feature-hooks-return-str-1.md.

Checks

In sidecar/: pytest 100 passed, pyright 0 errors, ruff check clean.

🤖 Generated with Claude Code

nigelgilbert and others added 5 commits November 22, 2026 04:35
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@nigelgilbert
nigelgilbert marked this pull request as ready for review November 22, 2026 11:18
nigelgilbert and others added 5 commits November 22, 2026 05:18
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@nigelgilbert
nigelgilbert merged commit c7fc7de into chore/pythonic-meditations-1 Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant