model_to_dict
Functions:
| Name | Description |
|---|---|
model_to_dict |
|
Functions#
model_to_dict #
Converts the model to a dict with unset optional properties excluded.
Performs a nested union on the dictionaries produced by setting the exclude_unset
and exclude_none options to True for the model.dict() method. This allows for
the preservation of explicit None values in the yaml, while still filtering out
values that default to None.
Borrowed approximately from https://stackoverflow.com/a/65363852/15641512.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
BaseModel
|
The pydantic model to dict-ify. |
required |
Returns:
| Type | Description |
|---|---|
Dict[Any, Any]
|
Dict[Any, Any]: The model as a dictionary. |