nested_set raises KeyError if not create_missing
This commit is contained in:
parent
783443e448
commit
3273b86b75
@ -55,7 +55,9 @@ def nested_set(target: dict, value: Any, *path: str, create_missing=True) -> dic
|
||||
elif create_missing:
|
||||
d = d.setdefault(key, {})
|
||||
else:
|
||||
return target
|
||||
raise KeyError(
|
||||
f"Key '{key}' is not found under path provided ({path}) and create_missing is False"
|
||||
)
|
||||
if path[-1] in d or create_missing:
|
||||
d[path[-1]] = value
|
||||
return target
|
||||
|
Loading…
Reference in New Issue
Block a user