forked from knocklabs/knock-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_pydantic.py
More file actions
18 lines (13 loc) · 763 Bytes
/
_pydantic.py
File metadata and controls
18 lines (13 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Central pydantic compatibility shim.
When pydantic v2 is installed, import from the bundled v1 compat layer
(pydantic.v1). When pydantic v1 is installed natively, import directly.
"""
from __future__ import annotations
import pydantic
if not pydantic.VERSION.startswith("1."):
from pydantic.v1 import Field, BaseModel, BaseConfig, PrivateAttr, ValidationError # type: ignore[no-redef]
from pydantic.v1.fields import FieldInfo # type: ignore[no-redef, assignment]
else:
from pydantic import Field, BaseModel, BaseConfig, PrivateAttr, ValidationError # type: ignore[assignment]
from pydantic.fields import FieldInfo # type: ignore[assignment]
__all__ = ["BaseConfig", "BaseModel", "Field", "FieldInfo", "PrivateAttr", "ValidationError"]