Skip to content

Commit 7f01286

Browse files
authored
Fix pydantic import for v2 (#121)
* Fix pydantic import for v2 * add comment * ignore mypy
1 parent 53fa001 commit 7f01286

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

launch/pydantic_schemas.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
from typing import Any, Dict, Set, Type, Union
33

44
from pydantic import BaseModel
5-
from pydantic.schema import get_flat_models_from_models, model_process_schema
5+
6+
try:
7+
from pydantic.schema import (
8+
get_flat_models_from_models,
9+
model_process_schema,
10+
)
11+
except ImportError:
12+
# We assume this is due to the user having pydantic 2.x installed.
13+
from pydantic.v1.schema import ( # type: ignore
14+
get_flat_models_from_models,
15+
model_process_schema,
16+
)
17+
618

719
REF_PREFIX = "#/components/schemas/"
820

0 commit comments

Comments
 (0)