fix: don't route non-widget attribute deletion through remove() - #740
Open
Sanjays2402 wants to merge 1 commit into
Open
fix: don't route non-widget attribute deletion through remove()#740Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
ContainerWidget.__delattr__ unconditionally called self.remove(name), so deleting any plain attribute that is not a current child widget raised ValueError from MutableSequence.remove -- including deleting a reference to a widget that had already been removed from the container. __delattr__ now looks for a matching child widget by name and removes it, otherwise falls back to object.__delattr__, which keeps normal Python semantics (AttributeError for a name that does not exist).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
==========================================
- Coverage 89.32% 89.31% -0.02%
==========================================
Files 40 40
Lines 4835 4839 +4
==========================================
+ Hits 4319 4322 +3
- Misses 516 517 +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.
Closes #739
ContainerWidget.__delattr__unconditionally calledself.remove(name), so deleting any plain attribute that is not a current child widget raisedValueErrorfromMutableSequence.remove— including deleting a reference to a widget that had already been removed from the container.__delattr__now removes a matching child widget by name and otherwise falls back toobject.__delattr__, which restores normal Python semantics (AttributeErrorfor a name that does not exist). The existingtest_delete_widgetstill covers the widget path.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.