Skip to content

Commit

Permalink
fix(dep): compat.py should import right pydantic class for pydantic >…
Browse files Browse the repository at this point in the history
…= 1.10.17 (#3710)
  • Loading branch information
roger-zhangg authored Jan 23, 2025
1 parent 888b8bd commit ceea00b
Showing 1 changed file with 7 additions and 0 deletions.
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"]

0 comments on commit ceea00b

Please sign in to comment.