You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The path for dictionary keys that are not Python literals is set to None. This causes issues when exclude_regex_paths is set.
To Reproduce
Run the following script:
import deepdiff
@dataclass(frozen=True)
class Id:
val: int
# Show that the repr properly represents the object
print(Id(2).__repr__())
d1 = {
Id(1): 10,
Id(2): 20,
}
d2 = {
Id(1): 10,
Id(2): 10,
}
print(deepdiff.DeepDiff(d1, d2, exclude_regex_paths=["any"]))
The traceback is
Id(val=2)
stringify_param was not able to get a proper repr for "Id(val=2)". This object will be reported as None. Add instructions for this object to DeepDiff's helper.literal_eval_extended to make it work properly: malformed node or string: <ast.Call object at 0x000001E071388C40>
Traceback (most recent call last):
File "scratch.py", line 24, in <module>
print(deepdiff.DeepDiff(d1, d2, exclude_regex_paths=["any"]))
File "py3.9\lib\site-packages\deepdiff\diff.py", line 320, in __init__
self._diff(root, parents_ids=frozenset({id(t1)}), _original_type=_original_type)
File "py3.9\lib\site-packages\deepdiff\diff.py", line 1562, in _diff
self._diff_dict(level, parents_ids, local_tree=local_tree)
File "py3.9\lib\site-packages\deepdiff\diff.py", line 616, in _diff_dict
self._diff(next_level, parents_ids_added, local_tree=local_tree)
File "py3.9\lib\site-packages\deepdiff\diff.py", line 1526, in _diff
if self._skip_this(level):
File "py3.9\lib\site-packages\deepdiff\diff.py", line 477, in _skip_this
[exclude_regex_path.search(level_path) for exclude_regex_path in self.exclude_regex_paths]):
File "py3.9\lib\site-packages\deepdiff\diff.py", line 477, in <listcomp>
[exclude_regex_path.search(level_path) for exclude_regex_path in self.exclude_regex_paths]):
TypeError: expected string or bytes-like object
Expected behavior
The DeepDiff should not fail when exclude_regex_paths is set, and should return the same results as when it is not specified if none of the paths match.
There is a parameter in stringify_param called force which seems to be meant to deal with this issue, but that parameter is never used:
Describe the bug
The path for dictionary keys that are not Python literals is set to None. This causes issues when
exclude_regex_paths
is set.To Reproduce
Run the following script:
The traceback is
Expected behavior
The DeepDiff should not fail when exclude_regex_paths is set, and should return the same results as when it is not specified if none of the paths match.
There is a parameter in
stringify_param
calledforce
which seems to be meant to deal with this issue, but that parameter is never used:deepdiff/deepdiff/model.py
Line 860 in 89c5cc2
OS, DeepDiff version and Python version (please complete the following information):
The text was updated successfully, but these errors were encountered: