Repository navigation
Make BoxList + and * return a BoxList - #359
Merged
Merged
Conversation
The out-of-place operators fell through to plain list, dropping the
class, the box options and the conversion of appended items:
BoxList([{'a': 1}]) + [{'b': 2}] -> plain list, second item a raw dict
BoxList([{'a': 1}]) * 2 -> plain list
__add__ and __mul__ now return a BoxList with the same box options;
appended items are converted the same way append/extend convert them,
and a frozen operand produces a frozen result. The in-place variants
were already correct.
Fixes cdgriffith#358
Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
cdgriffith
added a commit
that referenced
this pull request
Nov 11, 2026
# Conflicts: # test/test_box_list.py
Contributor
Author
|
Thanks for the merge on #359 ("Make BoxList + and * return a BoxList"). I'm also exploring my next role right now (Full Stack (PHP, NodeJs, Python) / Data Science / Applied AI / Devtools, based in India) — if you or your network is hiring, I'd love an intro: |
Merged
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.
Description
Fixes #358.
BoxList's out-of-place+and*operators fell through to plainlist, dropping the class, the box options and — for+— the conversion of appended items:What changes
__add__and__mul__now build the result throughBoxList.__init__, so:BoxListcarrying the left operand's box options;+are converted exactly likeappend/extendconvert them;Box.__add__'s frozen handling (the freeze happens after__init__has stored the items);+with a non-list and*with a non-int raiseBoxTypeError.The in-place variants (
+=,*=) were already correct and are unchanged.Validation Performed
TestBoxListOperators(test/test_box_list.py): all fail on master (plain-list results), all pass with this changetoml/toml-w-missing and ruamel-version artifacts on this host, unrelated to this change (identical failure list both runs)This change was made with the help of an AI agent, which located the missing operators and wrote the patch and tests under my direction.