MCPcopy Create free account
hub / github.com/fastapi/fastapi / serialize_sequence_value

Function serialize_sequence_value

fastapi/_compat/v2.py:366–376  ·  view source on GitHub ↗
(*, field: ModelField, value: Any)

Source from the content-addressed store, hash-verified

364
365
366def serialize_sequence_value(*, field: ModelField, value: Any) -> Sequence[Any]:
367 origin_type = get_origin(field.field_info.annotation) or field.field_info.annotation
368 if origin_type is Union or origin_type is UnionType: # Handle optional sequences
369 union_args = get_args(field.field_info.annotation)
370 for union_arg in union_args:
371 if union_arg is type(None):
372 continue
373 origin_type = get_origin(union_arg) or union_arg
374 break
375 assert issubclass(origin_type, shared.sequence_types) # type: ignore[arg-type] # ty: ignore[invalid-argument-type]
376 return shared.sequence_annotation_to_type[origin_type](value) # type: ignore[no-any-return,index] # ty: ignore[invalid-return-type]
377
378
379def get_missing_field_error(loc: tuple[int | str, ...]) -> dict[str, Any]:

Callers 1

_extract_form_bodyFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected