Skip to content

Commit 0b94d8e

Browse files
authored
Update docstring and type hint for lambda_handler (#95)
1 parent aa5a2bf commit 0b94d8e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ask-sdk-core/ask_sdk_core/skill_builder.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def create(self):
7878
return CustomSkill(skill_configuration=skill_configuration)
7979

8080
def lambda_handler(self):
81-
# type: () -> Callable[[RequestEnvelope, T], Dict[str, T]]
81+
# type: () -> Callable[[str, T], Dict[str, T]]
8282
"""Create a handler function that can be used as handler in
8383
AWS Lambda console.
8484
@@ -87,10 +87,21 @@ def lambda_handler(self):
8787
lambda_handler output to a variable and set the variable as
8888
AWS Lambda Handler on the console.
8989
90+
As mentioned in the `AWS Lambda Handler docs <https://docs.aws.
91+
amazon.com/lambda/latest/dg/python-programming-model-handler-types.html>`__,
92+
the handler function receives the event attribute as a ``str``
93+
representing the input request envelope JSON from Alexa service,
94+
which is deserialized to
95+
:py:class:`ask_sdk_model.request_envelope.RequestEnvelope`, before
96+
invoking the skill. The output from the handler function would
97+
be the serialized
98+
:py:class:`ask_sdk_model.response_envelope.ResponseEnvelope` class
99+
from the appropriate skill handler.
100+
90101
:return: Handler function to tag on AWS Lambda console.
91102
"""
92103
def wrapper(event, context):
93-
# type: (RequestEnvelope, T) -> Dict[str, T]
104+
# type: (str, T) -> Dict[str, T]
94105
skill = CustomSkill(skill_configuration=self.skill_configuration)
95106
request_envelope = skill.serializer.deserialize(
96107
payload=json.dumps(event), obj_type=RequestEnvelope)

0 commit comments

Comments
 (0)