inveniosoftware / inveniosoftware/dictdiffer

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

Open
#143 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
849
Forks
99
PR merge metrics
No merged PRs in 30d

Description

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.

```python
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]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.