fix(oocana): extract _wrap_output_with_warning to reduce duplication#454
Merged
leavesster merged 2 commits intomainfrom Feb 2, 2026
Merged
fix(oocana): extract _wrap_output_with_warning to reduce duplication#454leavesster merged 2 commits intomainfrom
leavesster merged 2 commits intomainfrom
Conversation
The output() and outputs() methods had duplicate try-except blocks for handling ValueError and IOError exceptions. This refactoring: - Extracts _wrap_output_with_warning() method for common error handling - Returns (value, success) tuple to simplify control flow - Reduces code duplication while maintaining identical behavior - Simplifies target handling logic in output()
演进概览在 变更
预估代码审查工作量🎯 2 (简单) | ⏱️ ~10 分钟 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extracts duplicate try/except error handling patterns from the output() and outputs() methods into a reusable helper method _wrap_output_with_warning() to reduce code duplication.
Changes:
- Added new helper method
_wrap_output_with_warning()that wraps output values with error handling and returns a success tuple - Refactored
output()method to use the new helper method instead of inline try/except blocks - Refactored
outputs()method to use the new helper method instead of inline try/except blocks - Minor code cleanup including whitespace fixes and type annotation improvements
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
_wrap_output_with_warning()method to handle output wrapping with error handlingoutput(),outputs(), andfinish()methodsProblem
Three methods had identical try/except patterns:
Solution
Extracted to a single helper method that returns
(wrapped_value, success)tuple.Test Plan