-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Would be nice to have the configs structure in the code
Right now we are deserializing the config data dynamically:
itf/score/itf/plugins/qemu/config.py
Lines 21 to 31 in e994cb6
| def _dict_to_obj(data): | |
| """ | |
| Recursively convert a dictionary to an object with attributes. | |
| Lists of dictionaries are converted to lists of objects. | |
| """ | |
| if isinstance(data, dict): | |
| return SimpleNamespace(**{key: _dict_to_obj(value) for key, value in data.items()}) | |
| elif isinstance(data, list): | |
| return [_dict_to_obj(item) for item in data] | |
| else: | |
| return data |
I think having the structure described by the code is nice for self documenting code + validation of the config.
Pydantic is a common library for this however it would introduce another dependency.
Alternatively there are ways to do this without dependencies:
https://stackoverflow.com/a/72013768
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog