-
-
Notifications
You must be signed in to change notification settings - Fork 256
Closed
Labels
Description
Describe the bug
When a path is excluded and ignore_order is True, DeepDiff prints out a warning:
Can not produce a hash for <object>. Not counting this object.
'<value> is not one of the hashed items.'
I don't think that this will ever produce bad results, since the object is being excluded, but I could be wrong.
To Reproduce
from deepdiff import DeepDiff
import re
t1 = { 'x': 0, 'y': [ 0, 'a', 'b', 'c' ] }
t2 = { 'x': 1, 'y': [ 1, 'c', 'b', 'a' ] }
exclude = [ re.compile(r"\['x'\]"), re.compile(r"\['y'\]\[0\]") ]
print(DeepDiff(t1,t2, exclude_regex_paths=exclude))
print(DeepDiff(t1,t2, ignore_order=True))
print(DeepDiff(t1,t2, ignore_order=True, exclude_regex_paths=exclude))
This produces:
{'values_changed': {"root['y'][1]": {'new_value': 'c', 'old_value': 'a'}, "root['y'][3]": {'new_value': 'a', 'old_value': 'c'}}}
{'values_changed': {"root['x']": {'new_value': 1, 'old_value': 0}, "root['y'][0]": {'new_value': 1, 'old_value': 0}}}
Can not produce a hash for root['y'].Not counting this object.
'0 is not one of the hashed items.'
Can not produce a hash for root['y'].Not counting this object.
'1 is not one of the hashed items.'
{}
Expected behavior
Shouldn't produce the warnings. Should just be:
{'values_changed': {"root['y'][1]": {'new_value': 'c', 'old_value': 'a'}, "root['y'][3]": {'new_value': 'a', 'old_value': 'c'}}}
{'values_changed': {"root['x']": {'new_value': 1, 'old_value': 0}, "root['y'][0]": {'new_value': 1, 'old_value': 0}}}
{}
OS, DeepDiff version and Python version (please complete the following information):
- OS: MacOS 11.6.1
- Python: 3.9.9
- DeepDiff: 5.7.0
Reactions are currently unavailable