Skip to content

Commit ceea00b

Browse files
authored
fix(dep): compat.py should import right pydantic class for pydantic >= 1.10.17 (#3710)
1 parent 888b8bd commit ceea00b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

samtranslator/compat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
try:
22
from pydantic import v1 as pydantic
3+
4+
# Starting Pydantic v1.10.17, pydantic import v1 will success,
5+
# adding the following line to make Pydantic v1 should fall back to v1 import correctly.
6+
pydantic.error_wrappers.ValidationError # noqa
37
except ImportError:
48
# Unfortunately mypy cannot handle this try/expect pattern, and "type: ignore"
59
# is the simplest work-around. See: https://github.com/python/mypy/issues/1153
610
import pydantic # type: ignore
11+
except AttributeError:
12+
# Pydantic v1.10.17+
13+
import pydantic # type: ignore
714

815
__all__ = ["pydantic"]

0 commit comments

Comments
 (0)