Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also supports pydantic v1. pydantic v2 provides v1 api through `pydantic.v1` import, so we can support both versions by trying to import from `pydantic.v1` and fallback to old behaviour. See https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features. pydantic == 2.0.0 does not work due to pydantic/pydantic#6361, so we need to blacklist that specific version.
- Loading branch information
Showing
11 changed files
with
53 additions
and
14 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,30 @@ | ||
__all__ = [ | ||
"BaseModel", | ||
"BaseSettings", | ||
"ValidationError", | ||
"parse_obj_as", | ||
"validator", | ||
"InitSettingsSource", | ||
] | ||
|
||
|
||
try: | ||
from pydantic.v1 import ( | ||
BaseModel, | ||
BaseSettings, | ||
ValidationError, | ||
parse_obj_as, | ||
validator, | ||
) | ||
from pydantic.v1.env_settings import InitSettingsSource | ||
except ImportError: | ||
from pydantic import ( # type: ignore[no-redef,assignment] | ||
BaseModel, | ||
BaseSettings, | ||
ValidationError, | ||
parse_obj_as, | ||
validator, | ||
) | ||
from pydantic.env_settings import ( # type: ignore[no-redef,assignment] | ||
InitSettingsSource, | ||
) |
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