fix: add missing type hints and improve test logging#12810
Merged
enyst merged 3 commits intoOpenHands:mainfrom Feb 18, 2026
Merged
fix: add missing type hints and improve test logging#12810enyst merged 3 commits intoOpenHands:mainfrom
enyst merged 3 commits intoOpenHands:mainfrom
Conversation
This PR includes several code quality improvements: 1. Add type hints to openhands/io/json.py: - Add return type annotation `-> str` to `dumps()` function - Add parameter type annotation `: str` and return type `-> Any` to `loads()` function - Import `Any` from typing module 2. Add type hint to openhands/memory/view.py: - Add return type annotation `-> Iterator[Event]` to `__iter__()` method - Import `Iterator` from collections.abc 3. Improve logging in tests/e2e/test_settings.py: - Replace all `print()` statements with proper logging using `logger.info()`, `logger.warning()`, and `logger.error()` - Add logging module import and create logger instance - This follows best practices for test logging and enables better log management These changes improve code quality, type safety, and maintainability without affecting functionality. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
Good improvements to type safety and logging! Found a few areas that could be enhanced further for consistency and best practices.
The Iterator[Event] type annotation conflicts with BaseModel's __iter__ method which returns Generator[tuple[str, Any], None, None]. Removing the explicit type annotation allows the method to work correctly.
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
This PR includes several code quality improvements to enhance type safety and logging practices:
openhands/io/json.pyopenhands/memory/view.pyprint()statements with proper logging intests/e2e/test_settings.pyChanges
1. Type hints in
openhands/io/json.py-> strtodumps()function: strand return type-> Anytoloads()functionAnyfrom typing module2. Type hint in
openhands/memory/view.py-> Iterator[Event]to__iter__()methodIteratorfrom collections.abc3. Logging improvements in
tests/e2e/test_settings.pyprint()statements with proper logging usinglogger.info(),logger.warning(), andlogger.error()Testing
The changes are minimal and focused:
Checklist
🤖 Generated with Claude Code