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

Function _extract_field_schema_pv2

src/openai/_models.py:817–835  ·  view source on GitHub ↗
(model: type[BaseModel], field_name: str)

Source from the content-addressed store, hash-verified

815
816
817def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None:
818 schema = model.__pydantic_core_schema__
819 if schema["type"] == "definitions":
820 schema = schema["schema"]
821
822 if schema["type"] != "model":
823 return None
824
825 schema = cast("ModelSchema", schema)
826 fields_schema = schema["schema"]
827 if fields_schema["type"] != "model-fields":
828 return None
829
830 fields_schema = cast("ModelFieldsSchema", fields_schema)
831 field = fields_schema["fields"].get(field_name)
832 if not field:
833 return None
834
835 return cast("ModelField", field) # pyright: ignore[reportUnnecessaryCast]
836
837
838def validate_type(*, type_: type[_T], value: object) -> _T:

Callers 1

Calls 1

getMethod · 0.45

Tested by

no test coverage detected