diff --git a/samtranslator/compat.py b/samtranslator/compat.py index 8c1c9ee55..7d2686d56 100644 --- a/samtranslator/compat.py +++ b/samtranslator/compat.py @@ -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"]