deepdiff
deepdiff copied to clipboard
Fix: Colored view displays empty list [] when all items are removed
Summary
Fixes a bug where COLORED_VIEW and COLORED_COMPACT_VIEW would display an empty list [] instead of showing removed items in red when all list items are removed.
Problem
When all items are removed from a list (t2 becomes empty), the colored view displays [] instead of the removed items in red.
Root Cause
In colored_view.py, _colorize_json() returned '[]' immediately when the list was empty, without checking for removed items.
Solution
Check for removed items before returning empty list representation.
Changes
- deepdiff/colored_view.py: Fixed early return logic
- tests/test_colored_view.py: Added 2 test cases
Testing
All 18 tests pass including 2 new tests for this bug.