From 5c87f2457764c3b663ba0b630ed1d4272681a52d Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 22 Jan 2025 23:30:08 +0000 Subject: [PATCH 1/3] fix compat.py --- samtranslator/compat.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/samtranslator/compat.py b/samtranslator/compat.py index 8c1c9ee55..d1d7249af 100644 --- a/samtranslator/compat.py +++ b/samtranslator/compat.py @@ -1,8 +1,14 @@ 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 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 - -__all__ = ["pydantic"] +except AttributeError: + # Pydantic v1.10.17+ + import pydantic # type: ignore + +__all__ = ["pydantic"] \ No newline at end of file From 0207e822b8947652fd8dc60740f6900146908121 Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 22 Jan 2025 23:40:43 +0000 Subject: [PATCH 2/3] format --- samtranslator/compat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samtranslator/compat.py b/samtranslator/compat.py index d1d7249af..a0e1a066f 100644 --- a/samtranslator/compat.py +++ b/samtranslator/compat.py @@ -1,6 +1,6 @@ try: from pydantic import v1 as pydantic - # Starting Pydantic v1.10.17, pydantic import v1 will success, + # 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 except ImportError: @@ -10,5 +10,5 @@ except AttributeError: # Pydantic v1.10.17+ import pydantic # type: ignore - -__all__ = ["pydantic"] \ No newline at end of file + +__all__ = ["pydantic"] From e56fc0a7054d78373ce599585c8b3c3e02261888 Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Thu, 23 Jan 2025 00:06:13 +0000 Subject: [PATCH 3/3] format --- samtranslator/compat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samtranslator/compat.py b/samtranslator/compat.py index a0e1a066f..7d2686d56 100644 --- a/samtranslator/compat.py +++ b/samtranslator/compat.py @@ -1,8 +1,9 @@ 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 + 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