-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from dbt-labs/backport-238-to-0.4.latest
[BACKPORT] #238 to 0.4.latest (Pydantic 2 Support)
- Loading branch information
Showing
12 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Dependencies | ||
body: Add support for pydantic 2 (and continue support for pydantic 1) | ||
time: 2023-12-21T13:04:18.792592-08:00 | ||
custom: | ||
Author: QMalcolm bernardcooke53 esciara | ||
PR: "134" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from importlib.metadata import version | ||
|
||
pydantic_version = version("pydantic") | ||
# Pydantic uses semantic versioning, i.e. <major>.<minor>.<patch>, and we need to know the major | ||
pydantic_major = pydantic_version.split(".")[0] | ||
|
||
if pydantic_major == "1": | ||
from pydantic import ( # type: ignore # noqa | ||
BaseModel, | ||
Extra, | ||
Field, | ||
create_model, | ||
root_validator, | ||
validator, | ||
) | ||
elif pydantic_major == "2": | ||
from pydantic.v1 import ( # type: ignore # noqa | ||
BaseModel, | ||
Extra, | ||
Field, | ||
create_model, | ||
root_validator, | ||
validator, | ||
) | ||
else: | ||
raise RuntimeError(f"Currently only pydantic 1 and 2 are supported, found pydantic {pydantic_version}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters