镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

The include_obj_callback has problems with nested dictionaries #519

Open

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions