Skip to main content

PrivateAttr

Indicates that an attribute is intended for private use and not handled during normal validation/serialization.

def PrivateAttr(
default: Any = PydanticUndefined,
default_factory: Callable[[], Any] | Callable[[dict[str, Any]], Any] | None = None,
init: Literal[False] = False
) - > ModelPrivateAttr

Indicates that an attribute is intended for private use and not handled during normal validation/serialization.

Parameters

NameTypeDescription
defaultAny = PydanticUndefinedThe attribute's default value used when no value is provided during model initialization.
default_factory`Callable[[], Any]Callable[[dict[str, Any]], Any]
initLiteral[False] = FalseWhether the attribute should be included in the constructor of the dataclass. Always False.

Returns

TypeDescription
ModelPrivateAttrAn instance of ModelPrivateAttr class used to define private model state.