Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
andresliszt committed Nov 24, 2024
1 parent 68955e6 commit b225197
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/serializers/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ impl SerField {
}
}


fn exclude_if(
exclude_if_callable: &Option<Py<PyAny>>,
value: &Bound<'_, PyAny>,
Expand All @@ -92,13 +91,7 @@ fn exclude_if(
Ok(false)
}


fn exclude_default(
value: &Bound<'_, PyAny>,
extra: &Extra,
serializer: &CombinedSerializer,
) -> PyResult<bool> {

fn exclude_default(value: &Bound<'_, PyAny>, extra: &Extra, serializer: &CombinedSerializer) -> PyResult<bool> {
if extra.exclude_defaults {
if let Some(default) = serializer.get_default(value.py())? {
if value.eq(default)? {
Expand Down Expand Up @@ -209,12 +202,8 @@ impl GeneralFieldsSerializer {
if exclude_if(&field.exclude_if, &value, serializer)? {
continue;
}
let value = serializer.to_python(
&value,
next_include.as_ref(),
next_exclude.as_ref(),
&field_extra,
)?;
let value =
serializer.to_python(&value, next_include.as_ref(), next_exclude.as_ref(), &field_extra)?;
let output_key = field.get_key_py(output_dict.py(), &field_extra);
output_dict.set_item(output_key, value)?;
}
Expand Down Expand Up @@ -294,9 +283,8 @@ impl GeneralFieldsSerializer {
if let Some((next_include, next_exclude)) = filter {
if let Some(field) = self.fields.get(key_str) {
if let Some(ref serializer) = field.serializer {
if exclude_default(&value, &field_extra, serializer)
.map_err(py_err_se_err)?{
continue;
if exclude_default(&value, &field_extra, serializer).map_err(py_err_se_err)? {
continue;
}
if exclude_if(&field.exclude_if, &value, serializer).map_err(py_err_se_err)? {
continue;
Expand Down

0 comments on commit b225197

Please sign in to comment.