Permit merging dict value with existing dict in user config

This commit is contained in:
jeremystretch 2023-02-21 16:25:52 -05:00
parent 7e1f4ef07e
commit 289836f9f6

View File

@ -140,7 +140,10 @@ class UserConfig(models.Model):
# Set a key based on the last item in the path. Raise TypeError if attempting to overwrite a non-leaf node.
key = keys[-1]
if key in d and type(d[key]) is dict:
raise TypeError(f"Key '{path}' has child keys; cannot assign a value")
if type(value) is dict:
d[key].update(value)
else:
raise TypeError(f"Key '{path}' is a dictionary; cannot assign a non-dictionary value")
else:
d[key] = value