Skip to content

Clean up dead code and fragile variable reference in LlamafileClient#73

Merged
antoinezambelli merged 2 commits into
antoinezambelli:mainfrom
hobostay:fix/dead-code-cleanup
May 25, 2026
Merged

Clean up dead code and fragile variable reference in LlamafileClient#73
antoinezambelli merged 2 commits into
antoinezambelli:mainfrom
hobostay:fix/dead-code-cleanup

Conversation

@hobostay
Copy link
Copy Markdown
Contributor

Summary

Two cleanups in LlamafileClient:

  1. Remove redundant or None: In _resolve_reasoning, line 241 has return accumulated_content or None inside a block already guarded by if accumulated_content:. Since accumulated_content is guaranteed truthy at this point, the or None is dead logic that can never evaluate to None.

  2. Replace fragile part reference with explicit bad_raw: In send_stream tool call parsing, the error fallback referenced part (the loop variable). This happened to be correct due to the break statement, but any future refactoring that removed or moved the break would silently reference the wrong tool call's arguments. Use an explicit bad_raw variable to capture the failing args at the point of failure.

Test plan

  • Verify LlamafileClient streaming still works correctly
  • Verify reasoning extraction still works
  • Run existing test suite

🤖 Generated with Claude Code

Test User and others added 2 commits May 20, 2026 21:07
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>
@antoinezambelli antoinezambelli merged commit acef4cb into antoinezambelli:main May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants