File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,15 +166,15 @@ def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
166166
167167
168168def model_parse_json (model : type [_ModelT ], data : str | bytes ) -> _ModelT :
169- if PYDANTIC_V2 :
170- return model .model_validate_json (data )
171- return model .parse_raw (data ) # pyright: ignore[reportDeprecated]
169+ if PYDANTIC_V1 :
170+ return model .parse_raw (data ) # pyright: ignore[reportDeprecated]
171+ return model .model_validate_json (data )
172172
173173
174174def model_json_schema (model : type [_ModelT ]) -> dict [str , Any ]:
175- if PYDANTIC_V2 :
176- return model .model_json_schema ()
177- return model .schema () # pyright: ignore[reportDeprecated]
175+ if PYDANTIC_V1 :
176+ return model .schema () # pyright: ignore[reportDeprecated]
177+ return model .model_json_schema ()
178178
179179
180180# generic models
Original file line number Diff line number Diff line change 66
77import pydantic
88
9- from .._compat import PYDANTIC_V2 , model_json_schema
9+ from .._compat import PYDANTIC_V1 , model_json_schema
1010
1111
1212def to_json_schema (
@@ -16,8 +16,8 @@ def to_json_schema(
1616 if is_basemodel_type (model_type ):
1717 schema = model_json_schema (model_type )
1818 elif isinstance (model_type , pydantic .TypeAdapter ):
19- if not PYDANTIC_V2 :
20- raise TypeError (f"TypeAdapters are only supported with Pydantic v2 - { model_type } " )
19+ if PYDANTIC_V1 :
20+ raise TypeError (f"TypeAdapters are not supported with Pydantic v1 - { model_type } " )
2121 schema = model_type .json_schema ()
2222 else :
2323 raise TypeError (f"Unsupported type: { model_type } " )
You can’t perform that action at this time.
0 commit comments