From 28ea5fa77867d118db92854b6e09bacd04711b59 Mon Sep 17 00:00:00 2001 From: Laurent LAPORTE Date: Thu, 21 Sep 2023 13:59:20 +0200 Subject: [PATCH] chore: correct handling of base class with no `__annotations__` in `AllOptionalMetaclass` This correction addresses an issue where the `AllOptionalMetaclass` metaclass was not handling cases where the base class has no `__annotations__` attribute properly. In such situations, this fix ensures that an empty annotation dictionary is assumed for correct behavior. --- antarest/study/business/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/antarest/study/business/utils.py b/antarest/study/business/utils.py index cdc2988ae4..b602c60138 100644 --- a/antarest/study/business/utils.py +++ b/antarest/study/business/utils.py @@ -66,6 +66,8 @@ class FormFieldsBaseModel(BaseModel): class Config: alias_generator = to_camel_case extra = Extra.forbid + validate_assignment = True + allow_population_by_field_name = True class FieldInfo(TypedDict, total=False): @@ -108,7 +110,7 @@ def __new__( ) -> Any: annotations = namespaces.get("__annotations__", {}) for base in bases: - annotations.update(base.__annotations__) + annotations.update(getattr(base, "__annotations__", {})) for field, field_type in annotations.items(): if not field.startswith("__"): # Optional fields are correctly handled