Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhly committed Oct 15, 2023
1 parent 4d830d7 commit e7d7a9a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/serializers/computed_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,17 @@ fn get_next_value<'a>(
input_value: &'a PyAny,
ob_type_lookup: &'a ObTypeLookup,
) -> PyResult<&'a PyAny> {
let next_value = match ob_type_lookup.get_type(input_value) {
ObType::Unknown | ObType::Dataclass => input_value.getattr(field.property_name_py.as_ref(input_value.py())),
_ => {
if field.has_ser_func {
Ok(input_value)
} else {
Err(PydanticSerializationError::new_err(format!(
"no serialization function found for {}",
field.property_name
)))
}
if field.has_ser_func {
return Ok(input_value);
}

match ob_type_lookup.get_type(input_value) {
ObType::Dataclass | ObType::PydanticSerializable | ObType::Unknown => {
input_value.getattr(field.property_name_py.as_ref(input_value.py()))
}
};
next_value
_ => Err(PydanticSerializationError::new_err(format!(
"no serialization function found for {}",
field.property_name
))),
}
}

0 comments on commit e7d7a9a

Please sign in to comment.