Skip to content

Commit 045d27a

Browse files
update references to deprecated pydantic V2
1 parent dc87604 commit 045d27a

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎src/parallel/_compat.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
166166

167167

168168
def 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

174174
def 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

‎src/parallel/lib/_pydantic.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pydantic
88

9-
from .._compat import PYDANTIC_V2, model_json_schema
9+
from .._compat import PYDANTIC_V1, model_json_schema
1010

1111

1212
def 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}")

0 commit comments

Comments
 (0)