MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / model_dump

Function model_dump

src/opencode_ai/_compat.py:133–158  ·  view source on GitHub ↗
(
    model: pydantic.BaseModel,
    *,
    exclude: IncEx | None = None,
    exclude_unset: bool = False,
    exclude_defaults: bool = False,
    warnings: bool = True,
    mode: Literal["json", "python"] = "python",
)

Source from the content-addressed store, hash-verified

131
132
133def model_dump(
134 model: pydantic.BaseModel,
135 *,
136 exclude: IncEx | None = None,
137 exclude_unset: bool = False,
138 exclude_defaults: bool = False,
139 warnings: bool = True,
140 mode: Literal["json", "python"] = "python",
141) -> dict[str, Any]:
142 if PYDANTIC_V2 or hasattr(model, "model_dump"):
143 return model.model_dump(
144 mode=mode,
145 exclude=exclude,
146 exclude_unset=exclude_unset,
147 exclude_defaults=exclude_defaults,
148 # warnings are not supported in Pydantic v1
149 warnings=warnings if PYDANTIC_V2 else True,
150 )
151 return cast(
152 "dict[str, Any]",
153 model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
154 exclude=exclude,
155 exclude_unset=exclude_unset,
156 exclude_defaults=exclude_defaults,
157 ),
158 )
159
160
161def model_parse(model: type[_ModelT], data: Any) -> _ModelT:

Calls 1

model_dumpMethod · 0.80