-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Greetings!
This is a similar issue to #23 except I have the list inside another Prodict. I seems like the exclude flag isn't getting passed down properly. I have attached another case to reproduce the issue and it currently occurs on 0.8.18.
#! /usr/bin/env python3
import json
from prodict import Prodict, List
class ImagesSource(Prodict):
dir: str
label: int
count: int
class ImageData(Prodict):
task_type: str
sources: List[ImagesSource]
class Config(Prodict):
image_data: ImageData
data = {
"image_data": {
"sources": [
{
"dir": "some/dir",
"label": 0
},
{
"dir": "other/dir",
"label": 1
}
]
}
}
model = Config.from_dict(data)
print(json.dumps(model.to_dict(exclude_none=True, exclude_none_in_lists=True, is_recursive=True)))
I get:
{"image_data": {"sources": [{"dir": "some/dir", "label": 0, "count": null}, {"dir": "other/dir", "label": 1, "count": null}]}}
I expect:
{"image_data": {"sources": [{"dir": "some/dir", "label": 0}, {"dir": "other/dir", "label": 1}]}}
Thanks for any help!
Metadata
Metadata
Assignees
Labels
No labels