Skip to content

Commit de7a6ef

Browse files
author
Michael Brewer
committed
chore(data-classes): Typing and docs
Changes: - Correct typing to make mypy happier - Correct highlighted lines
1 parent 4211796 commit de7a6ef

File tree

4 files changed

+39
-37
lines changed

4 files changed

+39
-37
lines changed

aws_lambda_powertools/utilities/data_classes/appsync/resolver_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def register_resolver(func):
2727

2828
return register_resolver
2929

30-
def resolve(self, event: dict, context: LambdaContext) -> Any:
31-
event = AppSyncResolverEvent(event)
30+
def resolve(self, _event: dict, context: LambdaContext) -> Any:
31+
event = AppSyncResolverEvent(_event)
3232
resolver, config = self._resolver(event.type_name, event.field_name)
3333
kwargs = self._kwargs(event, context, config)
3434
return resolver(**kwargs)

aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -292,26 +292,26 @@ class CustomMessageTriggerEventResponse(DictWrapper):
292292
def sms_message(self) -> str:
293293
return self["response"]["smsMessage"]
294294

295-
@property
296-
def email_message(self) -> str:
297-
return self["response"]["emailMessage"]
298-
299-
@property
300-
def email_subject(self) -> str:
301-
return self["response"]["emailSubject"]
302-
303295
@sms_message.setter
304296
def sms_message(self, value: str):
305297
"""The custom SMS message to be sent to your users.
306298
Must include the codeParameter value received in the request."""
307299
self["response"]["smsMessage"] = value
308300

301+
@property
302+
def email_message(self) -> str:
303+
return self["response"]["emailMessage"]
304+
309305
@email_message.setter
310306
def email_message(self, value: str):
311307
"""The custom email message to be sent to your users.
312308
Must include the codeParameter value received in the request."""
313309
self["response"]["emailMessage"] = value
314310

311+
@property
312+
def email_subject(self) -> str:
313+
return self["response"]["emailSubject"]
314+
315315
@email_subject.setter
316316
def email_subject(self, value: str):
317317
"""The subject line for the custom message."""
@@ -471,26 +471,26 @@ class ClaimsOverrideDetails(DictWrapper):
471471
def claims_to_add_or_override(self) -> Optional[Dict[str, str]]:
472472
return self.get("claimsToAddOrOverride")
473473

474-
@property
475-
def claims_to_suppress(self) -> Optional[List[str]]:
476-
return self.get("claimsToSuppress")
477-
478-
@property
479-
def group_configuration(self) -> Optional[GroupOverrideDetails]:
480-
group_override_details = self.get("groupOverrideDetails")
481-
return None if group_override_details is None else GroupOverrideDetails(group_override_details)
482-
483474
@claims_to_add_or_override.setter
484475
def claims_to_add_or_override(self, value: Dict[str, str]):
485476
"""A map of one or more key-value pairs of claims to add or override.
486477
For group related claims, use groupOverrideDetails instead."""
487478
self._data["claimsToAddOrOverride"] = value
488479

480+
@property
481+
def claims_to_suppress(self) -> Optional[List[str]]:
482+
return self.get("claimsToSuppress")
483+
489484
@claims_to_suppress.setter
490485
def claims_to_suppress(self, value: List[str]):
491486
"""A list that contains claims to be suppressed from the identity token."""
492487
self._data["claimsToSuppress"] = value
493488

489+
@property
490+
def group_configuration(self) -> Optional[GroupOverrideDetails]:
491+
group_override_details = self.get("groupOverrideDetails")
492+
return None if group_override_details is None else GroupOverrideDetails(group_override_details)
493+
494494
@group_configuration.setter
495495
def group_configuration(self, value: Dict[str, Any]):
496496
"""The output object containing the current group configuration.
@@ -609,25 +609,25 @@ class DefineAuthChallengeTriggerEventResponse(DictWrapper):
609609
def challenge_name(self) -> str:
610610
return self["response"]["challengeName"]
611611

612-
@property
613-
def fail_authentication(self) -> bool:
614-
return bool(self["response"]["failAuthentication"])
615-
616-
@property
617-
def issue_tokens(self) -> bool:
618-
return bool(self["response"]["issueTokens"])
619-
620612
@challenge_name.setter
621613
def challenge_name(self, value: str):
622614
"""A string containing the name of the next challenge.
623615
If you want to present a new challenge to your user, specify the challenge name here."""
624616
self["response"]["challengeName"] = value
625617

618+
@property
619+
def fail_authentication(self) -> bool:
620+
return bool(self["response"]["failAuthentication"])
621+
626622
@fail_authentication.setter
627623
def fail_authentication(self, value: bool):
628624
"""Set to true if you want to terminate the current authentication process, or false otherwise."""
629625
self["response"]["failAuthentication"] = value
630626

627+
@property
628+
def issue_tokens(self) -> bool:
629+
return bool(self["response"]["issueTokens"])
630+
631631
@issue_tokens.setter
632632
def issue_tokens(self, value: bool):
633633
"""Set to true if you determine that the user has been sufficiently authenticated by
@@ -695,21 +695,17 @@ class CreateAuthChallengeTriggerEventResponse(DictWrapper):
695695
def public_challenge_parameters(self) -> Dict[str, str]:
696696
return self["response"]["publicChallengeParameters"]
697697

698-
@property
699-
def private_challenge_parameters(self) -> Dict[str, str]:
700-
return self["response"]["privateChallengeParameters"]
701-
702-
@property
703-
def challenge_metadata(self) -> str:
704-
return self["response"]["challengeMetadata"]
705-
706698
@public_challenge_parameters.setter
707699
def public_challenge_parameters(self, value: Dict[str, str]):
708700
"""One or more key-value pairs for the client app to use in the challenge to be presented to the user.
709701
This parameter should contain all of the necessary information to accurately present the challenge to
710702
the user."""
711703
self["response"]["publicChallengeParameters"] = value
712704

705+
@property
706+
def private_challenge_parameters(self) -> Dict[str, str]:
707+
return self["response"]["privateChallengeParameters"]
708+
713709
@private_challenge_parameters.setter
714710
def private_challenge_parameters(self, value: Dict[str, str]):
715711
"""This parameter is only used by the Verify Auth Challenge Response Lambda trigger.
@@ -719,6 +715,10 @@ def private_challenge_parameters(self, value: Dict[str, str]):
719715
for the question."""
720716
self["response"]["privateChallengeParameters"] = value
721717

718+
@property
719+
def challenge_metadata(self) -> str:
720+
return self["response"]["challengeMetadata"]
721+
722722
@challenge_metadata.setter
723723
def challenge_metadata(self, value: str):
724724
"""Your name for the custom challenge, if this is a custom challenge."""

aws_lambda_powertools/utilities/data_classes/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def raw_event(self) -> Dict[str, Any]:
2525
return self._data
2626

2727

28-
def get_header_value(headers: Dict[str, str], name: str, default_value: str, case_sensitive: bool) -> Optional[str]:
28+
def get_header_value(
29+
headers: Dict[str, str], name: str, default_value: Optional[str], case_sensitive: Optional[bool]
30+
) -> Optional[str]:
2931
"""Get header value by name"""
3032
if case_sensitive:
3133
return headers.get(name, default_value)

docs/utilities/data_classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ This example is based on the AWS Blog post [Introducing Amazon S3 Object Lambda
554554

555555
=== "app.py"
556556

557-
```python hl_lines="4-5 10 12"
557+
```python hl_lines="5-6 12 14"
558558
import boto3
559559
import requests
560560

0 commit comments

Comments
 (0)