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

Function _construct_field

src/opencode_ai/_models.py:362–374  ·  view source on GitHub ↗
(value: object, field: FieldInfo, key: str)

Source from the content-addressed store, hash-verified

360
361
362def _construct_field(value: object, field: FieldInfo, key: str) -> object:
363 if value is None:
364 return field_get_default(field)
365
366 if PYDANTIC_V2:
367 type_ = field.annotation
368 else:
369 type_ = cast(type, field.outer_type_) # type: ignore
370
371 if type_ is None:
372 raise RuntimeError(f"Unexpected field type is None for {key}")
373
374 return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
375
376
377def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:

Callers 1

constructMethod · 0.85

Calls 2

field_get_defaultFunction · 0.85
construct_typeFunction · 0.85

Tested by

no test coverage detected