Clean up dead code and fragile variable reference in LlamafileClient#73
Open
hobostay wants to merge 1 commit into
Open
Clean up dead code and fragile variable reference in LlamafileClient#73hobostay wants to merge 1 commit into
hobostay wants to merge 1 commit into
Conversation
1. Remove redundant `or None` in _resolve_reasoning: the code is already inside `if accumulated_content:` so the value is guaranteed truthy — `or None` is dead logic that can never evaluate to None. 2. Replace fragile `part` reference with explicit `bad_raw` variable in send_stream tool call parsing. The `part` variable referenced the last iterated loop entry, which happened to be correct due to the `break` statement, but was fragile — any future refactoring of the loop body that removed or moved the break would silently reference the wrong tool call's arguments. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Two cleanups in LlamafileClient:
Remove redundant
or None: In_resolve_reasoning, line 241 hasreturn accumulated_content or Noneinside a block already guarded byif accumulated_content:. Sinceaccumulated_contentis guaranteed truthy at this point, theor Noneis dead logic that can never evaluate to None.Replace fragile
partreference with explicitbad_raw: Insend_streamtool call parsing, the error fallback referencedpart(the loop variable). This happened to be correct due to thebreakstatement, but any future refactoring that removed or moved the break would silently reference the wrong tool call's arguments. Use an explicitbad_rawvariable to capture the failing args at the point of failure.Test plan
🤖 Generated with Claude Code