Repository navigation
fix(BoxList): copy() returns a BoxList instead of a plain list - #362
Open
waseem1302-x wants to merge 5 commits into
Open
waseem1302-x wants to merge 5 commits into
waseem1302-x wants to merge 5 commits into
Conversation
Fix BoxList.copy() to return a BoxList instead of a plain list, preserving box_options and item comments.
Added Waseem Mushtaq to the list of authors.
This branch has not been deployed
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.
Hi, I'm Waseem Mushtaq, a final-year Computer Science undergraduate at Albukhary International University (AIU) in Malaysia on a full scholarship. I'm working on Python backend engineering, and I found this while using Box.
Bug
BoxList.copy()returns a plainlistinstead of aBoxList.Box.copy()returns aBox, andcopy.copy()on aBoxListreturns aBoxList, so only the.copy()method drops the type. The copy loses itsbox_options(box_dots,frozen_box,box_class) and its item comments. Worst case, a frozenBoxList's.copy()returns a mutable plain list, sofrozen.copy().append(3)succeeds.This is the same class of bug fixed in 8.0.1 for
BoxList+and*returning a plain list.Fix
Added
BoxList.copy()with the logic previously in__copy__(buildself.__class__withbox_options, copy item comments), and__copy__now delegates to it, mirroringBox. Also added thecopy()declaration tobox_list.pyi.Tests
test_copy_returns_a_box_list: type isBoxList,box_dotspreserved, dotted lookup workstest_copy_keeps_item_commentstest_copy_of_frozen_box_list_stays_frozen: type, options, mutation refused, hash equalThe new tests fail without the fix and pass with it. Full suite: 1227 passed, 1 skipped.
ruff check,ruff format --check, andmypy boxare clean.Thanks!