Fix option_dict_to_string flag serialization (missing f-string)#804
Merged
Conversation
For a valueless (flag-style) option, option_dict_to_string emitted the
literal string "{i}" instead of the option name, because the None branch
used a plain string literal rather than an f-string. Flags now serialize
as their name and round-trip cleanly through option_string_to_dict.
Also collapsed the accumulator loop into a single join expression.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #804 +/- ##
==========================================
- Coverage 76.19% 76.18% -0.01%
==========================================
Files 169 169
Lines 22268 22263 -5
==========================================
- Hits 16966 16960 -6
- Misses 5302 5303 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
sputils.option_dict_to_stringserialized a valueless (flag-style) option — one whose value isNone— as the literal string{i}instead of the option's name. TheNonebranch used a plain string literal where an f-string was intended:So, e.g.,
option_dict_to_string({'LogFile': None, 'mipgap': 0.01})returned'{i} mipgap=0.01 '.Fix
Use an f-string for the flag branch so flags serialize as their name and round-trip cleanly back through
option_string_to_dict. The accumulator loop is collapsed into a singlejoinwhile here.Behavior is unchanged for the other cases and preserves the docstring's "None begets None, empty begets empty" contract:
NoneNone{}''{'LogFile': None}'LogFile '{'mipgap': 0.01}'mipgap=0.01 '{'LogFile': None, 'mipgap': 0.01, 'threads': 4}'LogFile mipgap=0.01 threads=4 'All round-trip back through
option_string_to_dict.🤖 Generated with Claude Code