RootModel
RootModel class and type definitions.
RootModel ¶
RootModel(
__pydantic_self__, root=PydanticUndefined, **data
)
Bases: BaseModel
, typing.Generic[RootModelRootType]
A Pydantic BaseModel
for the root object of the model.
Attributes:
Name | Type | Description |
---|---|---|
root |
RootModelRootType
|
The root object of the model. |
__pydantic_root_model__ |
Whether the model is a RootModel. |
|
__pydantic_private__ |
Private fields in the model. |
|
__pydantic_extra__ |
Extra fields in the model. |
Source code in pydantic/root_model.py
43 44 45 46 47 48 49 50 51 |
|
model_construct
classmethod
¶
model_construct(root, _fields_set=None)
Create a new model using the provided root object and update fields set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root |
RootModelRootType
|
The root object of the model. |
required |
_fields_set |
set[str] | None
|
The set of fields to be updated. |
None
|
Returns:
Type | Description |
---|---|
Model
|
The new model. |
Raises:
Type | Description |
---|---|
NotImplemented
|
If the model is not a subclass of |
Source code in pydantic/root_model.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
model_dump ¶
model_dump(
*,
mode="python",
include=None,
exclude=None,
by_alias=False,
exclude_unset=False,
exclude_defaults=False,
exclude_none=False,
round_trip=False,
warnings=True
)
This method is included just to get a more accurate return type for type checkers.
It is included in this if TYPE_CHECKING:
block since no override is actually necessary.
See the documentation of BaseModel.model_dump
for more details about the arguments.
Source code in pydantic/root_model.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|