Skip to main content

rebuild_dataclass

Try to rebuild the pydantic-core schema for the dataclass.

def rebuild_dataclass(
cls: type[PydanticDataclass],
force: bool = False,
raise_errors: bool = True,
_parent_namespace_depth: int = 2,
_types_namespace: MappingNamespace | None = None
) - > bool | None

Try to rebuild the pydantic-core schema for the dataclass. This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters

NameTypeDescription
clstype[PydanticDataclass]The class to rebuild the pydantic-core schema for.
forcebool = FalseWhether to force the rebuilding of the schema, defaults to False.
raise_errorsbool = TrueWhether to raise errors, defaults to True.
_parent_namespace_depthint = 2The depth level of the parent namespace, defaults to 2.
_types_namespace`MappingNamespaceNone` = None

Returns

TypeDescription
`boolNone`