deepdiff
deepdiff copied to clipboard
exclude_obj_callback excludes when the condition is true for one variable
def func(obj, path):
return True if isinstance(obj, int) else False
t1 = {"x": "12"}
t2 = {"x": 1}
print(DeepDiff(t1, t2, exclude_obj_callback=func))
return
{}
func returns True only for t2, but exclude_obj_callback excludes objects from the result. Is this a bug or a feature? Maybe need to use AND instead of OR here: https://github.com/seperman/deepdiff/blob/9b70b2b5f17e345cb00aef74db7169b53f0c22e8/deepdiff/diff.py#L430 ?
If we put AND and the result shows up, I think it is gonna feel more like a bug than the current behavior, no?
We may have to introduce a new parameter that people can define whether it should be AND or OR.
Sep Dehpour
On May 14, 2022, at 11:11 AM, Mikhail @.***> wrote:
def func(obj, path): return True if isinstance(obj, int) else False
t1 = {"x": "12"} t2 = {"x": 1} print(DeepDiff(t1, t2, exclude_obj_callback=func)) return {}
func returns True only for t2, but exclude_obj_callback excludes objects from the result. Is this a bug or a feature? Maybe need to use AND instead of OR here: https://github.com/seperman/deepdiff/blob/9b70b2b5f17e345cb00aef74db7169b53f0c22e8/deepdiff/diff.py#L430 ?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.
I mean if we have a reference element with which we will compare other elements, then we will not validate other elements, we will always get True because of the reference element
in fact, I don't quite understand in which cases we may need specifically OR
That must have been a mistake. We should make it consistent between diff and hash. Thanks
Sep Dehpour
On May 24, 2022, at 3:10 PM, Mikhail @.***> wrote:
@seperman Why in deephash exclude_obj_callback use AND instead OR?: https://github.com/seperman/deepdiff/blob/81341e2827d083429bcdfb4617cd40e1188bbdb7/deepdiff/deephash.py#L335 also create PR with strict exclude_obj_callback #320
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.