deepdiff icon indicating copy to clipboard operation
deepdiff copied to clipboard

Fix: Colored view displays empty list [] when all items are removed

Open yannrouillard opened this issue 3 months ago • 0 comments

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.

yannrouillard avatar Nov 04 '25 19:11 yannrouillard