Skip to content

Commit

Permalink
Fix usage of pydantic v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonringer committed Feb 6, 2025
1 parent 9f0d08c commit cdf45e1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ typing_extensions>=4.4 # 3.8 doesn't have Required, TypeGuard and ParamSpec

# resource validation & schema generation
# 1.10.15 and 1.10.17 included breaking change from pydantic, more info: https://github.com/aws/serverless-application-model/issues/3617
pydantic>=1.8,<3,!=1.10.15,!=1.10.17
pydantic>=1.10.18,<3
2 changes: 1 addition & 1 deletion samtranslator/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# 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
pydantic.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
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def validate_properties_and_return_model(self, cls: Type[RT]) -> RT:
"""
try:
return cls.parse_obj(self._generate_resource_dict()["Properties"])
except pydantic.error_wrappers.ValidationError as e:
except pydantic.ValidationError as e:
error_properties: str = ""
with suppress(KeyError):
error_properties = ".".join(str(x) for x in e.errors()[0]["loc"])
Expand Down

0 comments on commit cdf45e1

Please sign in to comment.