Skip to main content

parse_obj_as

Parses an object into a specified type using a Pydantic TypeAdapter, though it is now deprecated in favor of pydantic.TypeAdapter.validate_python.

def parse_obj_as(
type_: type[T],
obj: Any,
type_name: NameFactory | None = null
) - > T

Parses and validates an arbitrary object against a specified Pydantic-compatible type. Note: This function is deprecated; use pydantic.TypeAdapter.validate_python instead.

Parameters

NameTypeDescription
type_type[T]The target Pydantic-compatible type or annotation to validate the object against
objAnyThe raw data or object to be parsed and validated
type_name`NameFactoryNone` = null

Returns

TypeDescription
TThe input object validated and coerced into the specified type T