@@ -136,7 +136,7 @@ def to_json_pickle(self):
136
136
"""
137
137
try :
138
138
import jsonpickle
139
- copied = self .copy ()
139
+ copied = self .copy () # type: ignore
140
140
return jsonpickle .encode (copied )
141
141
except ImportError : # pragma: no cover. Json pickle is getting deprecated.
142
142
logger .error ('jsonpickle library needs to be installed in order to run to_json_pickle' ) # pragma: no cover. Json pickle is getting deprecated.
@@ -210,8 +210,8 @@ def to_dict(self, view_override=None):
210
210
The options are the text or tree.
211
211
"""
212
212
213
- view = view_override if view_override else self .view
214
- return dict (self ._get_view_results (view ))
213
+ view = view_override if view_override else self .view # type: ignore
214
+ return dict (self ._get_view_results (view )) # type: ignore
215
215
216
216
def _to_delta_dict (self , directed = True , report_repetition_required = True , always_include_values = False ):
217
217
"""
@@ -236,12 +236,12 @@ def _to_delta_dict(self, directed=True, report_repetition_required=True, always_
236
236
was set to be True in the diff object.
237
237
238
238
"""
239
- if self .group_by is not None :
239
+ if self .group_by is not None : # type: ignore
240
240
raise ValueError (DELTA_ERROR_WHEN_GROUP_BY )
241
241
242
242
if directed and not always_include_values :
243
- _iterable_opcodes = {}
244
- for path , op_codes in self ._iterable_opcodes .items ():
243
+ _iterable_opcodes = {} # type: ignore
244
+ for path , op_codes in self ._iterable_opcodes .items (): # type: ignore
245
245
_iterable_opcodes [path ] = []
246
246
for op_code in op_codes :
247
247
new_op_code = Opcode (
@@ -254,29 +254,29 @@ def _to_delta_dict(self, directed=True, report_repetition_required=True, always_
254
254
)
255
255
_iterable_opcodes [path ].append (new_op_code )
256
256
else :
257
- _iterable_opcodes = self ._iterable_opcodes
257
+ _iterable_opcodes = self ._iterable_opcodes # type: ignore
258
258
259
259
result = DeltaResult (
260
- tree_results = self .tree ,
261
- ignore_order = self .ignore_order ,
260
+ tree_results = self .tree , # type: ignore
261
+ ignore_order = self .ignore_order , # type: ignore
262
262
always_include_values = always_include_values ,
263
263
_iterable_opcodes = _iterable_opcodes ,
264
264
)
265
265
result .remove_empty_keys ()
266
- if report_repetition_required and self .ignore_order and not self .report_repetition :
266
+ if report_repetition_required and self .ignore_order and not self .report_repetition : # type: ignore
267
267
raise ValueError (DELTA_IGNORE_ORDER_NEEDS_REPETITION_REPORT )
268
268
if directed :
269
269
for report_key , report_value in result .items ():
270
270
if isinstance (report_value , Mapping ):
271
271
for path , value in report_value .items ():
272
272
if isinstance (value , Mapping ) and 'old_value' in value :
273
- del value ['old_value' ]
274
- if self ._numpy_paths :
273
+ del value ['old_value' ] # type: ignore
274
+ if self ._numpy_paths : # type: ignore
275
275
# Note that keys that start with '_' are considered internal to DeepDiff
276
276
# and will be omitted when counting distance. (Look inside the distance module.)
277
- result ['_numpy_paths' ] = self ._numpy_paths
277
+ result ['_numpy_paths' ] = self ._numpy_paths # type: ignore
278
278
279
- if self .iterable_compare_func :
279
+ if self .iterable_compare_func : # type: ignore
280
280
result ['_iterable_compare_func_was_used' ] = True
281
281
282
282
return deepcopy (dict (result ))
@@ -299,9 +299,9 @@ def pretty(self, prefix: Optional[Union[str, Callable]]=None):
299
299
result = []
300
300
if prefix is None :
301
301
prefix = ''
302
- keys = sorted (self .tree .keys ()) # sorting keys to guarantee constant order across python versions.
302
+ keys = sorted (self .tree .keys ()) # type: ignore # sorting keys to guarantee constant order across python versions.
303
303
for key in keys :
304
- for item_key in self .tree [key ]:
304
+ for item_key in self .tree [key ]: # type: ignore
305
305
result += [pretty_print_diff (item_key )]
306
306
307
307
if callable (prefix ):
@@ -486,7 +486,7 @@ def load_path_content(path, file_type=None):
486
486
content = pickle_load (content )
487
487
elif file_type in {'csv' , 'tsv' }:
488
488
try :
489
- import clevercsv
489
+ import clevercsv # type: ignore
490
490
content = clevercsv .read_dicts (path )
491
491
except ImportError : # pragma: no cover.
492
492
import csv
@@ -633,7 +633,7 @@ class JSONDecoder(json.JSONDecoder):
633
633
def __init__ (self , * args , ** kwargs ):
634
634
json .JSONDecoder .__init__ (self , object_hook = self .object_hook , * args , ** kwargs )
635
635
636
- def object_hook (self , obj ):
636
+ def object_hook (self , obj ): # type: ignore
637
637
if 'old_type' in obj and 'new_type' in obj :
638
638
for type_key in ('old_type' , 'new_type' ):
639
639
type_str = obj [type_key ]
@@ -648,7 +648,7 @@ def json_dumps(
648
648
force_use_builtin_json : bool = False ,
649
649
return_bytes : bool = False ,
650
650
** kwargs ,
651
- ) -> str | bytes :
651
+ ) -> Union [ str , bytes ] :
652
652
"""
653
653
Dump json with extra details that are not normally json serializable
654
654
0 commit comments