From ceea00b390bbd3f0b91ab885d199e444dd63f0ff Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Thu, 23 Jan 2025 11:44:44 -0800 Subject: [PATCH] fix(dep): compat.py should import right pydantic class for pydantic >= 1.10.17 (#3710) --- samtranslator/compat.py | 7 +++++++ 1 file changed, 7 insertions(+) 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"]