Skip to content

Commit b742a34

Browse files
authored
fix: cs conversion takes into account all the parent classes (#753)
1 parent 584d4e6 commit b742a34

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

diracx-core/src/diracx/core/config/schema.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ def legacy_adaptor(cls, v):
4848
"SerializableSet[str]",
4949
"SerializableSet[SecurityProperty]",
5050
}
51-
for field, hint in cls.__annotations__.items():
51+
52+
# To support inheritance, we have to find the annotation of all the MRO
53+
# Skip the first classes (object, Pydantic.BaseModel, our BaseModel )
54+
mro_annotations = {}
55+
for mro_cls in cls.__mro__[::-1]:
56+
if issubclass(mro_cls, BaseModel) and mro_cls != BaseModel:
57+
mro_annotations.update(mro_cls.__annotations__)
58+
59+
for field, hint in mro_annotations.items():
5260
# Convert comma separated lists to actual lists
5361
if hint.startswith("set"):
5462
raise NotImplementedError("Use SerializableSet instead!")

0 commit comments

Comments
 (0)