File tree 1 file changed +10
-9
lines changed
aws_lambda_powertools/utilities/parser
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -83,16 +83,17 @@ def handler(event: Order, context: LambdaContext):
83
83
When envelope given does not implement BaseEnvelope
84
84
"""
85
85
86
- # The first parameter of a Lambda function is always the event
87
- # This line get the model informed in the event_parser function
88
- # or the first parameter of the function by using typing.get_type_hints
89
- type_hints = typing .get_type_hints (handler )
90
- model = model or (list (type_hints .values ())[0 ] if type_hints else None )
91
86
if model is None :
92
- raise InvalidModelTypeError (
93
- "The model must be provided either as the `model` argument to `event_parser`"
94
- "or as the type hint of `event` in the handler that it wraps" ,
95
- )
87
+ # The first parameter of a Lambda function is always the event.
88
+ # Get the first parameter's type by using typing.get_type_hints.
89
+ type_hints = typing .get_type_hints (handler )
90
+ if type_hints :
91
+ model = list (type_hints .values ())[0 ]
92
+ if model is None :
93
+ raise InvalidModelTypeError (
94
+ "The model must be provided either as the `model` argument to `event_parser`"
95
+ "or as the type hint of `event` in the handler that it wraps" ,
96
+ )
96
97
97
98
if envelope :
98
99
parsed_event = parse (event = event , model = model , envelope = envelope )
You can’t perform that action at this time.
0 commit comments