Skip to main content

computed_field

ComputedFields are properties of a model or dataclass that are included in serialization.

def computed_field(
property_name: str,
return_schema: CoreSchema,
alias: str | None = None,
serialization_exclude_if: Callable[[Any], bool] | None = None,
metadata: dict[str, Any] | None = None
) - > ComputedField

ComputedFields are properties of a model or dataclass that are included in serialization.

Parameters

NameTypeDescription
property_namestrThe name of the property on the model or dataclass
return_schemaCoreSchemaThe schema used for the type returned by the computed field
alias`strNone` = None
serialization_exclude_if`Callable[[Any], bool]None` = None
metadata`dict[str, Any]None` = None

Returns

TypeDescription
ComputedFieldA dictionary configuration object representing the computed field schema for pydantic-core