pythonize
pythonize copied to clipboard
Treat `NoneType` fields as `None`/missing during deserialization of mappings
trafficstars
MCVE:
Rust side:
#[derive(Deserialize)]
struct Foo {
#[serde(default)]
foo: bool,
}
python side:
foo = {
"foo": None,
}
depythonize::<Foo>(...) will fail with unexpected type: 'NoneType' object cannot be converted to '...'. However {} as input will work.
As far as I've looked, a check might be missing around here: https://github.com/davidhewitt/pythonize/blob/4491cdb46f35ab3fc1b419beef92171fbef510da/src/de.rs#L450 If that's the case I can look into it open PR with the fix.