@@ -171,7 +171,7 @@ def reset(self):
171
171
self .post_process_paths_to_convert = dict_ ()
172
172
173
173
def __add__ (self , other ):
174
- if isinstance (other , numbers ) and self ._numpy_paths :
174
+ if isinstance (other , numbers ) and self ._numpy_paths : # type: ignore
175
175
raise DeltaNumpyOperatorOverrideError (DELTA_NUMPY_OPERATOR_OVERRIDE_MSG )
176
176
if self .mutate :
177
177
self .root = other
@@ -240,7 +240,7 @@ def _get_elem_and_compare_to_old_value(
240
240
if action == GET :
241
241
current_old_value = obj [elem ]
242
242
elif action == GETATTR :
243
- current_old_value = getattr (obj , elem )
243
+ current_old_value = getattr (obj , elem ) # type: ignore
244
244
else :
245
245
raise DeltaError (INVALID_ACTION_WHEN_CALLING_GET_ELEM .format (action ))
246
246
except (KeyError , IndexError , AttributeError , TypeError ) as e :
@@ -261,7 +261,7 @@ def _get_elem_and_compare_to_old_value(
261
261
else :
262
262
obj [elem ] = _forced_old_value
263
263
elif action == GETATTR :
264
- setattr (obj , elem , _forced_old_value )
264
+ setattr (obj , elem , _forced_old_value ) # type: ignore
265
265
return _forced_old_value
266
266
current_old_value = not_found
267
267
if isinstance (path_for_err_reporting , (list , tuple )):
@@ -289,7 +289,7 @@ def _simple_set_elem_value(self, obj, path_for_err_reporting, elem=None, value=N
289
289
else :
290
290
self ._raise_or_log (ELEM_NOT_FOUND_TO_ADD_MSG .format (elem , path_for_err_reporting ))
291
291
elif action == GETATTR :
292
- setattr (obj , elem , value )
292
+ setattr (obj , elem , value ) # type: ignore
293
293
else :
294
294
raise DeltaError (INVALID_ACTION_WHEN_CALLING_SIMPLE_SET_ELEM .format (action ))
295
295
except (KeyError , IndexError , AttributeError , TypeError ) as e :
@@ -457,8 +457,8 @@ def _do_item_added(self, items, sort=True, insert=False):
457
457
continue # pragma: no cover. Due to cPython peephole optimizer, this line doesn't get covered. https://github.com/nedbat/coveragepy/issues/198
458
458
459
459
# Insert is only true for iterables, make sure it is a valid index.
460
- if (insert and elem < len (obj )):
461
- obj .insert (elem , None )
460
+ if (insert and elem < len (obj )): # type: ignore
461
+ obj .insert (elem , None ) # type: ignore
462
462
463
463
self ._set_new_value (parent , parent_to_obj_elem , parent_to_obj_action ,
464
464
obj , elements , path , elem , action , new_value )
@@ -482,7 +482,7 @@ def _do_post_process(self):
482
482
def _do_pre_process (self ):
483
483
if self ._numpy_paths and ('iterable_item_added' in self .diff or 'iterable_item_removed' in self .diff ):
484
484
preprocess_paths = dict_ ()
485
- for path , type_ in self ._numpy_paths .items ():
485
+ for path , type_ in self ._numpy_paths .items (): # type: ignore
486
486
preprocess_paths [path ] = {'old_type' : np_ndarray , 'new_type' : list }
487
487
try :
488
488
type_ = numpy_dtype_string_to_type (type_ )
@@ -507,7 +507,7 @@ def _get_elements_and_details(self, path):
507
507
parent_to_obj_elem , parent_to_obj_action = elements [- 2 ]
508
508
obj = self ._get_elem_and_compare_to_old_value (
509
509
obj = parent , path_for_err_reporting = path , expected_old_value = None ,
510
- elem = parent_to_obj_elem , action = parent_to_obj_action , next_element = next2_element )
510
+ elem = parent_to_obj_elem , action = parent_to_obj_action , next_element = next2_element ) # type: ignore
511
511
else :
512
512
# parent = self
513
513
# obj = self.root
@@ -516,7 +516,7 @@ def _get_elements_and_details(self, path):
516
516
parent = parent_to_obj_elem = parent_to_obj_action = None
517
517
obj = self
518
518
# obj = self.get_nested_obj(obj=self, elements=elements[:-1])
519
- elem , action = elements [- 1 ]
519
+ elem , action = elements [- 1 ] # type: ignore
520
520
except Exception as e :
521
521
self ._raise_or_log (UNABLE_TO_GET_ITEM_MSG .format (path , e ))
522
522
return None
@@ -550,7 +550,7 @@ def _do_values_or_type_changed(self, changes, is_type_change=False, verify_chang
550
550
else :
551
551
new_value = new_type (current_old_value )
552
552
except Exception as e :
553
- self ._raise_or_log (TYPE_CHANGE_FAIL_MSG .format (obj [elem ], value .get ('new_type' , 'unknown' ), e ))
553
+ self ._raise_or_log (TYPE_CHANGE_FAIL_MSG .format (obj [elem ], value .get ('new_type' , 'unknown' ), e )) # type: ignore
554
554
continue
555
555
else :
556
556
new_value = value ['new_value' ]
@@ -582,7 +582,7 @@ def _do_item_removed(self, items):
582
582
current_old_value = not_found
583
583
try :
584
584
if action == GET :
585
- current_old_value = obj [elem ]
585
+ current_old_value = obj [elem ] # type: ignore
586
586
elif action == GETATTR :
587
587
current_old_value = getattr (obj , elem )
588
588
look_for_expected_old_value = current_old_value != expected_old_value
@@ -644,15 +644,15 @@ def _do_iterable_opcodes(self):
644
644
transformed .extend (opcode .new_values )
645
645
elif opcode .tag == 'equal' :
646
646
# Items are the same in both lists, so we add them to the result
647
- transformed .extend (obj [opcode .t1_from_index :opcode .t1_to_index ])
647
+ transformed .extend (obj [opcode .t1_from_index :opcode .t1_to_index ]) # type: ignore
648
648
if is_obj_tuple :
649
- obj = tuple (obj )
649
+ obj = tuple (obj ) # type: ignore
650
650
# Making sure that the object is re-instated inside the parent especially if it was immutable
651
651
# and we had to turn it into a mutable one. In such cases the object has a new id.
652
652
self ._simple_set_elem_value (obj = parent , path_for_err_reporting = path , elem = parent_to_obj_elem ,
653
653
value = obj , action = parent_to_obj_action )
654
654
else :
655
- obj [:] = transformed
655
+ obj [:] = transformed # type: ignore
656
656
657
657
658
658
@@ -745,7 +745,7 @@ def _do_ignore_order(self):
745
745
fixed_indexes = self .diff .get ('iterable_items_added_at_indexes' , dict_ ())
746
746
remove_indexes = self .diff .get ('iterable_items_removed_at_indexes' , dict_ ())
747
747
paths = SetOrdered (fixed_indexes .keys ()) | SetOrdered (remove_indexes .keys ())
748
- for path in paths :
748
+ for path in paths : # type: ignore
749
749
# In the case of ignore_order reports, we are pointing to the container object.
750
750
# Thus we add a [0] to the elements so we can get the required objects and discard what we don't need.
751
751
elem_and_details = self ._get_elements_and_details ("{}[0]" .format (path ))
@@ -1021,7 +1021,7 @@ def _from_flat_dicts(flat_dict_list):
1021
1021
result ['_iterable_opcodes' ][path_str ] = []
1022
1022
result ['_iterable_opcodes' ][path_str ].append (
1023
1023
Opcode (
1024
- tag = FLAT_DATA_ACTION_TO_OPCODE_TAG [action ],
1024
+ tag = FLAT_DATA_ACTION_TO_OPCODE_TAG [action ], # type: ignore
1025
1025
t1_from_index = flat_dict .get ('t1_from_index' ),
1026
1026
t1_to_index = flat_dict .get ('t1_to_index' ),
1027
1027
t2_from_index = flat_dict .get ('t2_from_index' ),
@@ -1091,7 +1091,7 @@ def to_flat_dicts(self, include_action_in_path=False, report_type_changes=True)
1091
1091
"""
1092
1092
return [
1093
1093
i ._asdict () for i in self .to_flat_rows (include_action_in_path = False , report_type_changes = True )
1094
- ]
1094
+ ] # type: ignore
1095
1095
1096
1096
def to_flat_rows (self , include_action_in_path = False , report_type_changes = True ) -> List [FlatDeltaRow ]:
1097
1097
"""
@@ -1141,13 +1141,13 @@ def to_flat_rows(self, include_action_in_path=False, report_type_changes=True) -
1141
1141
for index , value in index_to_value .items ():
1142
1142
path2 = path .copy ()
1143
1143
if include_action_in_path :
1144
- path2 .append ((index , 'GET' ))
1144
+ path2 .append ((index , 'GET' )) # type: ignore
1145
1145
else :
1146
1146
path2 .append (index )
1147
1147
if report_type_changes :
1148
- row = FlatDeltaRow (path = path2 , value = value , action = new_action , type = type (value ))
1148
+ row = FlatDeltaRow (path = path2 , value = value , action = new_action , type = type (value )) # type: ignore
1149
1149
else :
1150
- row = FlatDeltaRow (path = path2 , value = value , action = new_action )
1150
+ row = FlatDeltaRow (path = path2 , value = value , action = new_action ) # type: ignore
1151
1151
result .append (row )
1152
1152
elif action in {'set_item_added' , 'set_item_removed' }:
1153
1153
for path , values in info .items ():
@@ -1167,15 +1167,15 @@ def to_flat_rows(self, include_action_in_path=False, report_type_changes=True) -
1167
1167
value = value [new_key ]
1168
1168
elif isinstance (value , (list , tuple )) and len (value ) == 1 :
1169
1169
value = value [0 ]
1170
- path .append (0 )
1170
+ path .append (0 ) # type: ignore
1171
1171
action = 'iterable_item_added'
1172
1172
elif isinstance (value , set ) and len (value ) == 1 :
1173
1173
value = value .pop ()
1174
1174
action = 'set_item_added'
1175
1175
if report_type_changes :
1176
- row = FlatDeltaRow (path = path , value = value , action = action , type = type (value ))
1176
+ row = FlatDeltaRow (path = path , value = value , action = action , type = type (value )) # type: ignore
1177
1177
else :
1178
- row = FlatDeltaRow (path = path , value = value , action = action )
1178
+ row = FlatDeltaRow (path = path , value = value , action = action ) # type: ignore
1179
1179
result .append (row )
1180
1180
elif action in {
1181
1181
'dictionary_item_removed' , 'iterable_item_added' ,
0 commit comments