Skip to content

fix: replace Optional[callable] with Optional[Callable] in type annotations#33920

Closed
blut-agent wants to merge 1 commit into
NousResearch:mainfrom
blut-agent:fix/type-annotations-callable-20260528
Closed

fix: replace Optional[callable] with Optional[Callable] in type annotations#33920
blut-agent wants to merge 1 commit into
NousResearch:mainfrom
blut-agent:fix/type-annotations-callable-20260528

Conversation

@blut-agent

Copy link
Copy Markdown
Contributor

Problem

The builtin callable is not a valid generic type for static type checkers like mypy/pyright. While Optional[callable] works at runtime (Python accepts it), it's technically incorrect and would flag errors in strict type-checking mode.

This pattern appeared in 6 files across the codebase.

Fix

Replace all instances of Optional[callable] with the correct Optional[Callable[...]] annotation, adding the missing Callable import where needed.

Files changed:

  • hermes_cli/dingtalk_auth.pyon_waiting: Optional[Callable[[], None]]
  • run_agent.pystream_callback: Optional[Callable[[str], None]] (2 places)
  • agent/conversation_loop.pystream_callback: Optional[Callable[[str], None]]
  • gateway/stream_consumer.pyon_new_message: Optional[Callable[[], None]] (already had Callable imported but used lowercase)
  • tools/delegate_tool.py — return type Optional[Callable[..., None]]
  • plugins/disk-cleanup/disk_cleanup.pyconfirm: Optional[Callable[[Dict[str, Any]], bool]]

Testing

  • No runtime behavior change — this is purely a type annotation fix
  • All 6 files pass lint checks (no new errors introduced)

…ations

The builtin 'callable' is not a valid generic type for static type checkers.
Replace all instances of Optional[callable] with the correct typing.Callable
annotation, and add the missing 'Callable' import where needed.

Files fixed:
- hermes_cli/dingtalk_auth.py: on_waiting callback
- run_agent.py: stream_callback in chat() and run_conversation()
- agent/conversation_loop.py: stream_callback in run_conversation()
- gateway/stream_consumer.py: on_new_message callback
- tools/delegate_tool.py: _build_child_progress_callback return type
- plugins/disk-cleanup/disk_cleanup.py: confirm callback in deep()
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation labels May 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Subset of #32985 (which covers Optional[callable] + Optional[any] fixes) and also overlaps with #32869 (omnibus 13-fix PR addressing #32848 items 10 and 13). This PR is narrower in scope — callable only.

@blut-agent

Copy link
Copy Markdown
Contributor Author

Closing — this is a subset of #32985 (still open, covers Callable + Any fixes) and overlaps with #32869. The broader PR is the right place for this fix. Thanks @alt-glitch for flagging.

@blut-agent blut-agent closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have tool/delegate Subagent delegation type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants