Skip to content

Commit 856f660

Browse files
committed
chore: tech debt to make json deserialization cleaner
1 parent 8ce83a8 commit 856f660

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

aws_lambda_powertools/utilities/parser/models/sqs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class SqsMsgAttributeModel(BaseModel):
5252
class SqsRecordModel(BaseModel):
5353
messageId: str
5454
receiptHandle: str
55-
body: Union[str, Type[BaseModel]]
55+
body: Union[str, Type[BaseModel], BaseModel]
5656
attributes: SqsAttributesModel
5757
messageAttributes: Dict[str, SqsMsgAttributeModel]
5858
md5OfBody: str

aws_lambda_powertools/utilities/parser/types.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
import sys
44
from typing import Any, Dict, Type, TypeVar, Union
55

6-
from pydantic import BaseModel
6+
from pydantic import BaseModel, Json
77

88
# We only need typing_extensions for python versions <3.8
99
if sys.version_info >= (3, 8):
10-
from typing import Literal # noqa: F401
10+
from typing import Literal
1111
else:
12-
from typing_extensions import Literal # noqa: F401
12+
from typing_extensions import Literal
1313

1414
Model = TypeVar("Model", bound=BaseModel)
1515
EnvelopeModel = TypeVar("EnvelopeModel")
1616
EventParserReturnType = TypeVar("EventParserReturnType")
1717
AnyInheritedModel = Union[Type[BaseModel], BaseModel]
1818
RawDictOrModel = Union[Dict[str, Any], AnyInheritedModel]
19+
20+
__all__ = ["Json", "Literal"]

0 commit comments

Comments
 (0)