MCPcopy
hub / github.com/openai/openai-python / _construct_field

Function _construct_field

src/openai/_models.py:505–517  ·  view source on GitHub ↗
(value: object, field: FieldInfo, key: str)

Source from the content-addressed store, hash-verified

503
504
505def _construct_field(value: object, field: FieldInfo, key: str) -> object:
506 if value is None:
507 return field_get_default(field)
508
509 if PYDANTIC_V1:
510 type_ = cast(type, field.outer_type_) # type: ignore
511 else:
512 type_ = field.annotation # type: ignore
513
514 if type_ is None:
515 raise RuntimeError(f"Unexpected field type is None for {key}")
516
517 return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
518
519
520def _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