From 74d5120cdbb5b7af616b2f0e181e8a7864fa645e Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Tue, 30 Apr 2024 20:51:56 +0300 Subject: [PATCH] data_models: allow list assignment in `set_or_update_a_value` --- rendercv/data_models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rendercv/data_models.py b/rendercv/data_models.py index 96938a5..dd73bdc 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -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):