4
4
from decimal import Decimal
5
5
from deepdiff import DeepDiff
6
6
from deepdiff .serialization import pickle_load
7
- from deepdiff .helper import py_current_version , strings
7
+ from deepdiff .helper import py_current_version , strings , short_repr
8
8
from deepdiff .path import _path_to_elements , _get_nested_obj , GET , GETATTR
9
9
10
10
MINIMUM_PY_FOR_DELTA = Decimal ('3.6' )
@@ -114,6 +114,9 @@ def __init__(self, diff=None, delta_path=None, mutate=False, verify_symmetry=Fal
114
114
self .raise_errors = raise_errors
115
115
self .log_errors = log_errors
116
116
117
+ def __repr__ (self ):
118
+ return "<Delta: {}>" .format (short_repr (self .diff , max_length = 100 ))
119
+
117
120
def reset (self ):
118
121
self .post_process_paths_to_convert = {}
119
122
@@ -127,13 +130,14 @@ def __add__(self, other):
127
130
self ._do_set_item_added ()
128
131
self ._do_set_item_removed ()
129
132
self ._do_type_changes ()
133
+ # NOTE: the remove iterable action needs to happen BEFORE
134
+ # all the other iterables to match the reverse of order of operations in DeepDiff
135
+ self ._do_iterable_item_removed ()
130
136
self ._do_iterable_item_added ()
131
137
self ._do_dictionary_item_added ()
132
138
self ._do_dictionary_item_removed ()
133
139
self ._do_attribute_added ()
134
140
self ._do_attribute_removed ()
135
- # NOTE: the remove iterable action needs to happen AFTER all the other iterables.
136
- self ._do_iterable_item_removed ()
137
141
self ._do_post_process ()
138
142
139
143
other = self .root
@@ -371,7 +375,6 @@ def _do_set_item(self, items, func):
371
375
self ._simple_set_elem_value (parent , path_for_err_reporting = path , elem = elem , value = new_value , action = action )
372
376
373
377
374
-
375
378
if __name__ == "__main__" : # pragma: no cover
376
379
import doctest
377
380
doctest .testmod ()
0 commit comments