fix(type-annotations): replace Optional[callable] with proper Callable types - #50844
Closed
blut-agent wants to merge 1 commit into
Closed
fix(type-annotations): replace Optional[callable] with proper Callable types#50844blut-agent wants to merge 1 commit into
blut-agent wants to merge 1 commit into
Conversation
…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
Collaborator
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace 8 instances of
Optional[callable]with properCallabletypes fromtyping.The Python builtin
callable(lowercase) is not a valid generic type for static type checkers. UsingOptional[callable]works at runtime but will flag errors in strict mypy/pyright mode.Files Changed
tools/delegate_tool.pyOptional[callable]→Optional[Callable[..., None]](return type of_build_child_progress_callback)hermes_cli/dingtalk_auth.pyOptional[callable]→Optional[Callable[[], None]](on_waitingparam)plugins/disk-cleanup/disk_cleanup.pyOptional[callable]→Optional[Callable[[Dict[str, Any]], bool]](confirmparam)run_agent.pyOptional[callable]→Optional[Callable[[str], None]](2xstream_callbackparams)agent/conversation_loop.pyOptional[callable]→Optional[Callable[[str], None]](stream_callbackparam)gateway/stream_consumer.pyOptional[callable]→Optional[Callable[[], None]](on_new_messageparam)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 currentmain.Verification
Optional[callable]instances in the codebase