(type_: typing.Type[T], object_: typing.Any)
| 57 | |
| 58 | |
| 59 | def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: |
| 60 | dealiased_object = convert_and_respect_annotation_metadata( |
| 61 | object_=object_, annotation=type_, direction="read" |
| 62 | ) |
| 63 | if IS_PYDANTIC_V2: |
| 64 | adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 |
| 65 | return adapter.validate_python(dealiased_object) |
| 66 | else: |
| 67 | return pydantic.parse_obj_as(type_, dealiased_object) |
| 68 | |
| 69 | |
| 70 | def to_jsonable_with_fallback( |
no test coverage detected