@@ -171,7 +171,7 @@ def reset(self):
171171 self .post_process_paths_to_convert = dict_ ()
172172
173173 def __add__ (self , other ):
174- if isinstance (other , numbers ) and self ._numpy_paths :
174+ if isinstance (other , numbers ) and self ._numpy_paths : # type: ignore
175175 raise DeltaNumpyOperatorOverrideError (DELTA_NUMPY_OPERATOR_OVERRIDE_MSG )
176176 if self .mutate :
177177 self .root = other
@@ -240,7 +240,7 @@ def _get_elem_and_compare_to_old_value(
240240 if action == GET :
241241 current_old_value = obj [elem ]
242242 elif action == GETATTR :
243- current_old_value = getattr (obj , elem )
243+ current_old_value = getattr (obj , elem ) # type: ignore
244244 else :
245245 raise DeltaError (INVALID_ACTION_WHEN_CALLING_GET_ELEM .format (action ))
246246 except (KeyError , IndexError , AttributeError , TypeError ) as e :
@@ -261,7 +261,7 @@ def _get_elem_and_compare_to_old_value(
261261 else :
262262 obj [elem ] = _forced_old_value
263263 elif action == GETATTR :
264- setattr (obj , elem , _forced_old_value )
264+ setattr (obj , elem , _forced_old_value ) # type: ignore
265265 return _forced_old_value
266266 current_old_value = not_found
267267 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
289289 else :
290290 self ._raise_or_log (ELEM_NOT_FOUND_TO_ADD_MSG .format (elem , path_for_err_reporting ))
291291 elif action == GETATTR :
292- setattr (obj , elem , value )
292+ setattr (obj , elem , value ) # type: ignore
293293 else :
294294 raise DeltaError (INVALID_ACTION_WHEN_CALLING_SIMPLE_SET_ELEM .format (action ))
295295 except (KeyError , IndexError , AttributeError , TypeError ) as e :
@@ -457,8 +457,8 @@ def _do_item_added(self, items, sort=True, insert=False):
457457 continue # pragma: no cover. Due to cPython peephole optimizer, this line doesn't get covered. https://github.com/nedbat/coveragepy/issues/198
458458
459459 # 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
462462
463463 self ._set_new_value (parent , parent_to_obj_elem , parent_to_obj_action ,
464464 obj , elements , path , elem , action , new_value )
@@ -482,7 +482,7 @@ def _do_post_process(self):
482482 def _do_pre_process (self ):
483483 if self ._numpy_paths and ('iterable_item_added' in self .diff or 'iterable_item_removed' in self .diff ):
484484 preprocess_paths = dict_ ()
485- for path , type_ in self ._numpy_paths .items ():
485+ for path , type_ in self ._numpy_paths .items (): # type: ignore
486486 preprocess_paths [path ] = {'old_type' : np_ndarray , 'new_type' : list }
487487 try :
488488 type_ = numpy_dtype_string_to_type (type_ )
@@ -507,7 +507,7 @@ def _get_elements_and_details(self, path):
507507 parent_to_obj_elem , parent_to_obj_action = elements [- 2 ]
508508 obj = self ._get_elem_and_compare_to_old_value (
509509 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
511511 else :
512512 # parent = self
513513 # obj = self.root
@@ -516,7 +516,7 @@ def _get_elements_and_details(self, path):
516516 parent = parent_to_obj_elem = parent_to_obj_action = None
517517 obj = self
518518 # obj = self.get_nested_obj(obj=self, elements=elements[:-1])
519- elem , action = elements [- 1 ]
519+ elem , action = elements [- 1 ] # type: ignore
520520 except Exception as e :
521521 self ._raise_or_log (UNABLE_TO_GET_ITEM_MSG .format (path , e ))
522522 return None
@@ -550,7 +550,7 @@ def _do_values_or_type_changed(self, changes, is_type_change=False, verify_chang
550550 else :
551551 new_value = new_type (current_old_value )
552552 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
554554 continue
555555 else :
556556 new_value = value ['new_value' ]
@@ -582,7 +582,7 @@ def _do_item_removed(self, items):
582582 current_old_value = not_found
583583 try :
584584 if action == GET :
585- current_old_value = obj [elem ]
585+ current_old_value = obj [elem ] # type: ignore
586586 elif action == GETATTR :
587587 current_old_value = getattr (obj , elem )
588588 look_for_expected_old_value = current_old_value != expected_old_value
@@ -644,15 +644,15 @@ def _do_iterable_opcodes(self):
644644 transformed .extend (opcode .new_values )
645645 elif opcode .tag == 'equal' :
646646 # 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
648648 if is_obj_tuple :
649- obj = tuple (obj )
649+ obj = tuple (obj ) # type: ignore
650650 # Making sure that the object is re-instated inside the parent especially if it was immutable
651651 # and we had to turn it into a mutable one. In such cases the object has a new id.
652652 self ._simple_set_elem_value (obj = parent , path_for_err_reporting = path , elem = parent_to_obj_elem ,
653653 value = obj , action = parent_to_obj_action )
654654 else :
655- obj [:] = transformed
655+ obj [:] = transformed # type: ignore
656656
657657
658658
@@ -745,7 +745,7 @@ def _do_ignore_order(self):
745745 fixed_indexes = self .diff .get ('iterable_items_added_at_indexes' , dict_ ())
746746 remove_indexes = self .diff .get ('iterable_items_removed_at_indexes' , dict_ ())
747747 paths = SetOrdered (fixed_indexes .keys ()) | SetOrdered (remove_indexes .keys ())
748- for path in paths :
748+ for path in paths : # type: ignore
749749 # In the case of ignore_order reports, we are pointing to the container object.
750750 # Thus we add a [0] to the elements so we can get the required objects and discard what we don't need.
751751 elem_and_details = self ._get_elements_and_details ("{}[0]" .format (path ))
@@ -1021,7 +1021,7 @@ def _from_flat_dicts(flat_dict_list):
10211021 result ['_iterable_opcodes' ][path_str ] = []
10221022 result ['_iterable_opcodes' ][path_str ].append (
10231023 Opcode (
1024- tag = FLAT_DATA_ACTION_TO_OPCODE_TAG [action ],
1024+ tag = FLAT_DATA_ACTION_TO_OPCODE_TAG [action ], # type: ignore
10251025 t1_from_index = flat_dict .get ('t1_from_index' ),
10261026 t1_to_index = flat_dict .get ('t1_to_index' ),
10271027 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)
10911091 """
10921092 return [
10931093 i ._asdict () for i in self .to_flat_rows (include_action_in_path = False , report_type_changes = True )
1094- ]
1094+ ] # type: ignore
10951095
10961096 def to_flat_rows (self , include_action_in_path = False , report_type_changes = True ) -> List [FlatDeltaRow ]:
10971097 """
@@ -1141,13 +1141,13 @@ def to_flat_rows(self, include_action_in_path=False, report_type_changes=True) -
11411141 for index , value in index_to_value .items ():
11421142 path2 = path .copy ()
11431143 if include_action_in_path :
1144- path2 .append ((index , 'GET' ))
1144+ path2 .append ((index , 'GET' )) # type: ignore
11451145 else :
11461146 path2 .append (index )
11471147 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
11491149 else :
1150- row = FlatDeltaRow (path = path2 , value = value , action = new_action )
1150+ row = FlatDeltaRow (path = path2 , value = value , action = new_action ) # type: ignore
11511151 result .append (row )
11521152 elif action in {'set_item_added' , 'set_item_removed' }:
11531153 for path , values in info .items ():
@@ -1167,15 +1167,15 @@ def to_flat_rows(self, include_action_in_path=False, report_type_changes=True) -
11671167 value = value [new_key ]
11681168 elif isinstance (value , (list , tuple )) and len (value ) == 1 :
11691169 value = value [0 ]
1170- path .append (0 )
1170+ path .append (0 ) # type: ignore
11711171 action = 'iterable_item_added'
11721172 elif isinstance (value , set ) and len (value ) == 1 :
11731173 value = value .pop ()
11741174 action = 'set_item_added'
11751175 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
11771177 else :
1178- row = FlatDeltaRow (path = path , value = value , action = action )
1178+ row = FlatDeltaRow (path = path , value = value , action = action ) # type: ignore
11791179 result .append (row )
11801180 elif action in {
11811181 'dictionary_item_removed' , 'iterable_item_added' ,
0 commit comments