fix: colored view not showing removed items when list is emptied (#575)#586
Open
r266-tech wants to merge 1 commit intoqlustered:masterfrom
Open
fix: colored view not showing removed items when list is emptied (#575)#586r266-tech wants to merge 1 commit intoqlustered:masterfrom
r266-tech wants to merge 1 commit intoqlustered:masterfrom
Conversation
When comparing a list with an empty list using COLORED_VIEW, all removed items were silently dropped from the output. The empty list check (if not obj: return '[]') ran before checking for removed items. Fix: move the empty check after collecting removed_map, and only return '[]' if both the object is empty AND there are no removed items. Fixes qlustered#575
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.
Problem
When comparing a list with an empty list using
COLORED_VIEW, all removed items are silently dropped from the output. Thestr()representation returns[]instead of showing the removed items.Reproduction
Root Cause
In
deepdiff/colored_view.py, the list branch of_colorize_jsonchecksif not obj: return '[]'before collecting removed items viaself._get_path_removed(path). Whent2is empty, the function returns immediately without ever checking for removed items.Fix
Move the empty check after collecting
removed_map, and only return'[]'if both the object is empty AND there are no removed items.Testing
test_colored_view_list_all_removedto cover the empty list caseFixes #575