Skip to content

Commit

Permalink
chore: correct handling of base class with no __annotations__ in `A…
Browse files Browse the repository at this point in the history
…llOptionalMetaclass`

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.
  • Loading branch information
laurent-laporte-pro committed Sep 21, 2023
1 parent 97768f6 commit 28ea5fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion antarest/study/business/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 28ea5fa

Please sign in to comment.