A simple utility to visualize DeepDiff in the terminal. Support rich for even prettier renders.
pip install deepdiff_viewerTo use the RichViewer class:
pip install deepdiff_viewer[rich]Simple usage:
from deepdiff import DeepDiff
from deepdiff_viewer.rich import RichViewer
t1 = {"a": 1}
t2 = {"a": 3}
ddiff = DeepDiff(t1, t2, view="tree")
viewer = RichViewer(ddiff)
print(viewer.render())If you use pydantic for your models, the
RichViewer will use the model_dump function to render the model in a yaml
format when you add or delete new object. Otherwise the render would show you
the python class and not a pretty render of the object.
Note that pydantic is not a dependency of the project but will be imported if
it is found.
See the examples/ folder.
The DeepDiffTreeViewer class wraps a DeepDiff object that was built with
the tree view mode. It
generates a tree of all the differences found in the DeepDiff object so that
it can be rendered.
Currently the only implemented viewer is the RichViewer but you can
extend the DeepDiffTreeViewer base class to make your own viewer if you want
to use something else than rich.
MIT


