inveniosoftware / inveniosoftware/dictdiffer
For removed items in .patch() first check if exists before deleting
Open
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
Assessment
This issue has not been assessed yet.