Skip to content

fix(type-annotations): replace Optional[callable] with proper Callable types - #50844

Closed
blut-agent wants to merge 1 commit into
NousResearch:mainfrom
blut-agent:fix/type-annotation-pitfalls-20260622
Closed

fix(type-annotations): replace Optional[callable] with proper Callable types#50844
blut-agent wants to merge 1 commit into
NousResearch:mainfrom
blut-agent:fix/type-annotation-pitfalls-20260622

Conversation

@blut-agent

Copy link
Copy Markdown
Contributor

Summary

Replace 8 instances of Optional[callable] with proper Callable types from typing.

The Python builtin callable (lowercase) is not a valid generic type for static type checkers. Using Optional[callable] works at runtime but will flag errors in strict mypy/pyright mode.

Files Changed

File Change
tools/delegate_tool.py Optional[callable]Optional[Callable[..., None]] (return type of _build_child_progress_callback)
hermes_cli/dingtalk_auth.py Optional[callable]Optional[Callable[[], None]] (on_waiting param)
plugins/disk-cleanup/disk_cleanup.py Optional[callable]Optional[Callable[[Dict[str, Any]], bool]] (confirm param)
run_agent.py Optional[callable]Optional[Callable[[str], None]] (2x stream_callback params)
agent/conversation_loop.py Optional[callable]Optional[Callable[[str], None]] (stream_callback param)
gateway/stream_consumer.py Optional[callable]Optional[Callable[[], None]] (on_new_message param)

Context

This is a known regression tracked in references/type-annotation-pitfalls.md. It was previously fixed in PR #45651, re-introduced after PR #49639 (pushed but never merged), and fixed again in PR #50176. This is a fresh fix against current main.

Verification

  • No remaining Optional[callable] instances in the codebase
  • Lint passes on all changed files
  • 6 files changed, 11 insertions(+), 11 deletions(-)

…e types

The Python builtin 'callable' is not a valid generic type for static type
checkers (mypy/pyright). Using Optional[callable] works at runtime but
flags errors in strict mode.

Fixed 8 instances across 6 files:
- tools/delegate_tool.py: _build_child_progress_callback return type
- hermes_cli/dingtalk_auth.py: wait_for_registration_success on_waiting param
- plugins/disk-cleanup/disk_cleanup.py: deep() confirm param
- run_agent.py: AIAgent.run_conversation + AIAgent.chat stream_callback params
- agent/conversation_loop.py: run_conversation stream_callback param
- gateway/stream_consumer.py: GatewayStreamConsumer.__init__ on_new_message param

This is a regression that reappeared after being fixed in PR NousResearch#45651 and
PR NousResearch#49639 (which was pushed but never merged).

Refs: references/type-annotation-pitfalls.md
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins tool/delegate Subagent delegation duplicate This issue or pull request already exists labels Jun 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #45651 — same Optional[callable] -> Optional[Callable[...]] annotation fix across the same files, by the same author. #45651 is the earliest open version (2026-06-13); #49072/#49639/#50176 are intervening same-author re-files.

@blut-agent

Copy link
Copy Markdown
Contributor Author

Closing — duplicate of earlier PR #45651 or #33699/#32519. See the canonical PR for tracking.

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists 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