Skip to content

For removed items in .patch() first check if exists before deleting #143

@jlane9

Description

@jlane9

Package version (if known): 0.8.1

Describe the bug

Ran into a case where we tried to remove something that didn't actually exist in the target dictionary. Request: make the remove function under patch safer by checking to make sure the item exists before deletion. If the item is there, it'll delete it otherwise just ignore.

def remove(node, changes):
    for key, value in changes:
        dest = dot_lookup(destination, node)
        if isinstance(dest, SET_TYPES):
            dest -= value
        elif key in dest:  # **** Change this from else: ****
            del dest[key]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions