Skip to content

Commit 75c0cd9

Browse files
committed
fixing the typing
1 parent c05467c commit 75c0cd9

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

deepdiff/serialization.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def to_json_pickle(self):
136136
"""
137137
try:
138138
import jsonpickle
139-
copied = self.copy()
139+
copied = self.copy() # type: ignore
140140
return jsonpickle.encode(copied)
141141
except ImportError: # pragma: no cover. Json pickle is getting deprecated.
142142
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):
210210
The options are the text or tree.
211211
"""
212212

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
215215

216216
def _to_delta_dict(self, directed=True, report_repetition_required=True, always_include_values=False):
217217
"""
@@ -236,12 +236,12 @@ def _to_delta_dict(self, directed=True, report_repetition_required=True, always_
236236
was set to be True in the diff object.
237237
238238
"""
239-
if self.group_by is not None:
239+
if self.group_by is not None: # type: ignore
240240
raise ValueError(DELTA_ERROR_WHEN_GROUP_BY)
241241

242242
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
245245
_iterable_opcodes[path] = []
246246
for op_code in op_codes:
247247
new_op_code = Opcode(
@@ -254,29 +254,29 @@ def _to_delta_dict(self, directed=True, report_repetition_required=True, always_
254254
)
255255
_iterable_opcodes[path].append(new_op_code)
256256
else:
257-
_iterable_opcodes = self._iterable_opcodes
257+
_iterable_opcodes = self._iterable_opcodes # type: ignore
258258

259259
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
262262
always_include_values=always_include_values,
263263
_iterable_opcodes=_iterable_opcodes,
264264
)
265265
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
267267
raise ValueError(DELTA_IGNORE_ORDER_NEEDS_REPETITION_REPORT)
268268
if directed:
269269
for report_key, report_value in result.items():
270270
if isinstance(report_value, Mapping):
271271
for path, value in report_value.items():
272272
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
275275
# Note that keys that start with '_' are considered internal to DeepDiff
276276
# 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
278278

279-
if self.iterable_compare_func:
279+
if self.iterable_compare_func: # type: ignore
280280
result['_iterable_compare_func_was_used'] = True
281281

282282
return deepcopy(dict(result))
@@ -299,9 +299,9 @@ def pretty(self, prefix: Optional[Union[str, Callable]]=None):
299299
result = []
300300
if prefix is None:
301301
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.
303303
for key in keys:
304-
for item_key in self.tree[key]:
304+
for item_key in self.tree[key]: # type: ignore
305305
result += [pretty_print_diff(item_key)]
306306

307307
if callable(prefix):
@@ -486,7 +486,7 @@ def load_path_content(path, file_type=None):
486486
content = pickle_load(content)
487487
elif file_type in {'csv', 'tsv'}:
488488
try:
489-
import clevercsv
489+
import clevercsv # type: ignore
490490
content = clevercsv.read_dicts(path)
491491
except ImportError: # pragma: no cover.
492492
import csv
@@ -633,7 +633,7 @@ class JSONDecoder(json.JSONDecoder):
633633
def __init__(self, *args, **kwargs):
634634
json.JSONDecoder.__init__(self, object_hook=self.object_hook, *args, **kwargs)
635635

636-
def object_hook(self, obj):
636+
def object_hook(self, obj): # type: ignore
637637
if 'old_type' in obj and 'new_type' in obj:
638638
for type_key in ('old_type', 'new_type'):
639639
type_str = obj[type_key]
@@ -648,7 +648,7 @@ def json_dumps(
648648
force_use_builtin_json: bool = False,
649649
return_bytes: bool = False,
650650
**kwargs,
651-
) -> str | bytes:
651+
) -> Union[str, bytes]:
652652
"""
653653
Dump json with extra details that are not normally json serializable
654654

0 commit comments

Comments
 (0)