Skip to content

fix(dep): compat.py should import right pydantic class for pydantic >= 1.10.17 #3710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions samtranslator/compat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
try:
from pydantic import v1 as pydantic

# Starting Pydantic v1.10.17, pydantic import v1 will success,
# adding the following line to make Pydantic v1 should fall back to v1 import correctly.
pydantic.error_wrappers.ValidationError # noqa
except ImportError:
# Unfortunately mypy cannot handle this try/expect pattern, and "type: ignore"
# is the simplest work-around. See: https://github.com/python/mypy/issues/1153
import pydantic # type: ignore
except AttributeError:
# Pydantic v1.10.17+
import pydantic # type: ignore

__all__ = ["pydantic"]
Loading