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
Is your feature request related to a problem? Please describe.
I’m currently encountering the following error: Can not hash the following items: [ObjectId('688a718ef3748592f129959c')]
This seems incorrect, since ObjectId is a perfectly hashable object.
Describe the solution you'd like
I'd like to pass extra hash functions as a parameter to DeepDiff, i.e. DeepDiff(t1, t2, extra_hash_functions={ObjectId: hash})
Describe alternatives you've considered
Alternatively, DeepDiff could attempt to use Python’s built-in hash() function before giving up with the "Can not hash the following items" error.
or
Pass custom DeepHash class to use. DeepDiff(t1, t2, custom_deep_hash=MyDeepHashClass)
Additional context
To reproduce exactly my problem, you have to install pymongo.
Then run this code:
frombsonimportObjectId, SONfromdeepdiffimportDeepDifft1=SON([('list_reference', [ObjectId('688a718ef3748592f129959c')])])
t2=SON([('list_reference', [ObjectId('688a718ef3748592f129959c'), ObjectId('688a718ef3748592f129959d')])])
# `ignore_order` seems to be the key to reproduce the problem, please do not advice me to get rid of it, I need it :)diff=DeepDiff(t1=t1, t2=t2, ignore_order=True)
ifnotdiff:
print("DIFF IS EMPTY! WHY?")
else:
print(f"Diff: {diff}")
Activity