Skip to content

Missing property decorator on SerializationInfo.round_trip #1542

@viccie30

Description

@viccie30

In src/serializers/type_serializers/function.rs SerializationInfo::round_trip is defined as a property:

#[pyo3(get)]
round_trip: bool,

In python/pydantic_core/core_schema.py SerializationInfo.round_trip is defined as a method, however:

def round_trip(self) -> bool: ...

Trying to call SerializationInfo.round_trip in a model validator fails with a TypeError:

Error calling function `serialize_model`: TypeError: 'bool' object is not callable
  File "<source file>", line 108, in serialize_model
    round_trip=info.round_trip(),
               ^^^^^^^^^^^^^^^^^
TypeError: 'bool' object is not callable

The fix is simple, I think, just mark SerializationInfo.round_trip as a property in python/pydantic_core/core_schema.py. This fixes the type checking issues for my code. I don't have a full Rust development environment installed, so I can't test whether any other changes are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions