Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The include_obj_callback has problems with nested dictionaries #519

Open
shadow0202 opened this issue Feb 17, 2025 · 0 comments
Open

The include_obj_callback has problems with nested dictionaries #519

shadow0202 opened this issue Feb 17, 2025 · 0 comments

Comments

@shadow0202
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant