clan_lib: allow delete on non-existing data
This commit is contained in:
@@ -431,9 +431,11 @@ def delete_by_path(d: dict[str, Any], path: str) -> Any:
|
|||||||
last_key = keys[-1]
|
last_key = keys[-1]
|
||||||
try:
|
try:
|
||||||
value = current.pop(last_key)
|
value = current.pop(last_key)
|
||||||
except KeyError as exc:
|
except KeyError:
|
||||||
msg = f"Cannot delete. Path '{path}' not found in data '{d}'"
|
# Possibly data was already deleted
|
||||||
raise KeyError(msg) from exc
|
# msg = f"Canot delete. Path '{path}' not found in data '{d}'"
|
||||||
|
# raise KeyError(msg) from exc
|
||||||
|
return {}
|
||||||
else:
|
else:
|
||||||
return {last_key: value}
|
return {last_key: value}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user