Skip to content

The include_obj_callback has problems with nested dictionaries #519

Open
@shadow0202

Description

@shadow0202

Please checkout the F.A.Q page before creating a bug ticket to make sure it is not already addressed.

Describe the bug
In the nested dictionaries, the include_obj_callback parameter doesn't work right; it only checks the fields at the top level, not the ones deeper inside.

To Reproduce

def include_obj_callback2(obj, path):
    print(path)
    return True if "cc" in path else False

t1 = {"x_cc": 120, "y_cc": "4b", "z_cc": "c", "sdf": {"include_cc": "a", "asdf":"!@#"}}
t2 = {"x_cc": 10, "y_cc": "b", "z_cc": "c22", "sdf": {"include_cc": "b12", "asdf":"!@#22"}}
res = DeepDiff(t1, t2, include_obj_callback=include_obj_callback2)
print(res)

result I got:

root['x_cc']
root['x_cc']
root['y_cc']
root['y_cc']
root['z_cc']
root['z_cc']
root['sdf']
root['sdf']
{'values_changed': {"root['x_cc']": {'new_value': 10, 'old_value': 120}, "root['y_cc']": {'new_value': 'b', 'old_value': '4b'}, "root['z_cc']": {'new_value': 'c22', 'old_value': 'c'}}}

"include_cc" is not detected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions