data_models: allow list assignment in `set_or_update_a_value`

This commit is contained in:
Sina Atalay 2024-04-30 20:51:56 +03:00
parent f2eea31b35
commit 74d5120cdb
1 changed files with 5 additions and 2 deletions

View File

@ -1133,7 +1133,7 @@ class RenderCVDataModel(RenderCVBaseModel):
def set_or_update_a_value(
data_model: pydantic.BaseModel | dict | list,
key: str,
value: Any,
value: str,
sub_model: pydantic.BaseModel | dict | list = None,
):
"""Set or update a value in a data model for a specific key. For example, a key can
@ -1162,7 +1162,10 @@ def set_or_update_a_value(
if len(keys) == 1:
# set the value:
if value.startswith("{") and value.endswith("}"):
# allow users to assign dictionaries directly in the input file:
# allow users to assign dictionaries:
value = eval(value)
elif value.startswith("[") and value.endswith("]"):
# allow users to assign lists:
value = eval(value)
if isinstance(model, pydantic.BaseModel):