Skip to content

Commit 24ab726

Browse files
author
Michael Brewer
authored
fix(data-classes): docstring typos and clean up (#937)
1 parent b70ceb2 commit 24ab726

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(
101101
only be used during development.
102102
allow_headers: Optional[List[str]]
103103
The list of additional allowed headers. This list is added to list of
104-
built in allowed headers: `Authorization`, `Content-Type`, `X-Amz-Date`,
104+
built-in allowed headers: `Authorization`, `Content-Type`, `X-Amz-Date`,
105105
`X-Api-Key`, `X-Amz-Security-Token`.
106106
expose_headers: Optional[List[str]]
107107
A list of values to return for the Access-Control-Expose-Headers

aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ def __init__(
2828
self.api_id = api_id
2929
self.stage = stage
3030
self.http_method = http_method
31-
self.resource = resource
31+
# Remove matching "/" from `resource`.
32+
self.resource = resource.lstrip("/")
3233

3334
@property
3435
def arn(self) -> str:
35-
"""Build an arn from it's parts
36+
"""Build an arn from its parts
3637
eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request"""
3738
return (
3839
f"arn:{self.partition}:execute-api:{self.region}:{self.aws_account_id}:{self.api_id}/{self.stage}/"
@@ -168,7 +169,7 @@ def get_header_value(
168169
default_value: str, optional
169170
Default value if no value was found by name
170171
case_sensitive: bool
171-
Whether to use a case sensitive look up
172+
Whether to use a case-sensitive look up
172173
Returns
173174
-------
174175
str, optional
@@ -270,7 +271,7 @@ def get_header_value(
270271
default_value: str, optional
271272
Default value if no value was found by name
272273
case_sensitive: bool
273-
Whether to use a case sensitive look up
274+
Whether to use a case-sensitive look up
274275
Returns
275276
-------
276277
str, optional
@@ -440,9 +441,6 @@ def _add_route(self, effect: str, http_method: str, resource: str, conditions: O
440441
if not self._resource_pattern.match(resource):
441442
raise ValueError(f"Invalid resource path: {resource}. Path should match {self.path_regex}")
442443

443-
if resource[:1] == "/":
444-
resource = resource[1:]
445-
446444
resource_arn = APIGatewayRouteArn(
447445
self.region, self.aws_account_id, self.api_id, self.stage, http_method, resource
448446
).arn

aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def source_ip(self) -> List[str]:
2727

2828
@property
2929
def username(self) -> str:
30-
"""The user name of the authenticated user. IAM user principal"""
30+
"""The username of the authenticated user. IAM user principal"""
3131
return self["username"]
3232

3333
@property
@@ -72,7 +72,7 @@ def source_ip(self) -> List[str]:
7272

7373
@property
7474
def username(self) -> str:
75-
"""The user name of the authenticated user."""
75+
"""The username of the authenticated user."""
7676
return self["username"]
7777

7878
@property
@@ -172,7 +172,7 @@ def arguments(self) -> Dict[str, Any]:
172172
def identity(self) -> Union[None, AppSyncIdentityIAM, AppSyncIdentityCognito]:
173173
"""An object that contains information about the caller.
174174
175-
Depending of the type of identify found:
175+
Depending on the type of identify found:
176176
177177
- API_KEY authorization - returns None
178178
- AWS_IAM authorization - returns AppSyncIdentityIAM
@@ -223,7 +223,7 @@ def get_header_value(
223223
default_value: str, optional
224224
Default value if no value was found by name
225225
case_sensitive: bool
226-
Whether to use a case sensitive look up
226+
Whether to use a case-sensitive look up
227227
Returns
228228
-------
229229
str, optional

aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def final_user_status(self) -> Optional[str]:
195195
@final_user_status.setter
196196
def final_user_status(self, value: str):
197197
"""During sign-in, this attribute can be set to CONFIRMED, or not set, to auto-confirm your users and
198-
allow them to sign-in with their previous passwords. This is the simplest experience for the user.
198+
allow them to sign in with their previous passwords. This is the simplest experience for the user.
199199
200200
If this attribute is set to RESET_REQUIRED, the user is required to change his or her password immediately
201201
after migration at the time of sign-in, and your client app needs to handle the PasswordResetRequiredException
@@ -333,7 +333,7 @@ class CustomMessageTriggerEvent(BaseTriggerEvent):
333333
verification code automatically to the user. Cannot be used for other attributes.
334334
- `CustomMessage_VerifyUserAttribute` This trigger sends a verification code to the user when they manually
335335
request it for a new email or phone number.
336-
- `CustomMessage_Authentication` To send MFA code during authentication.
336+
- `CustomMessage_Authentication` To send MFA codes during authentication.
337337
338338
Documentation:
339339
--------------
@@ -590,7 +590,7 @@ def user_attributes(self) -> Dict[str, str]:
590590
@property
591591
def user_not_found(self) -> Optional[bool]:
592592
"""A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client.
593-
A value of true means that the user id (user name, email address, etc.) did not match any existing users."""
593+
A value of true means that the user id (username, email address, etc.) did not match any existing users."""
594594
return self["request"].get("userNotFound")
595595

596596
@property
@@ -601,7 +601,7 @@ def session(self) -> List[ChallengeResult]:
601601
@property
602602
def client_metadata(self) -> Optional[Dict[str, str]]:
603603
"""One or more key-value pairs that you can provide as custom input to the Lambda function that you specify
604-
for the define auth challenge trigger."""
604+
for the defined auth challenge trigger."""
605605
return self["request"].get("clientMetadata")
606606

607607

@@ -687,7 +687,7 @@ def session(self) -> List[ChallengeResult]:
687687
@property
688688
def client_metadata(self) -> Optional[Dict[str, str]]:
689689
"""One or more key-value pairs that you can provide as custom input to the Lambda function that you
690-
specify for the create auth challenge trigger."""
690+
specify for the creation auth challenge trigger."""
691691
return self["request"].get("clientMetadata")
692692

693693

@@ -699,7 +699,7 @@ def public_challenge_parameters(self) -> Dict[str, str]:
699699
@public_challenge_parameters.setter
700700
def public_challenge_parameters(self, value: Dict[str, str]):
701701
"""One or more key-value pairs for the client app to use in the challenge to be presented to the user.
702-
This parameter should contain all of the necessary information to accurately present the challenge to
702+
This parameter should contain all the necessary information to accurately present the challenge to
703703
the user."""
704704
self["response"]["publicChallengeParameters"] = value
705705

@@ -709,8 +709,8 @@ def private_challenge_parameters(self) -> Dict[str, str]:
709709

710710
@private_challenge_parameters.setter
711711
def private_challenge_parameters(self, value: Dict[str, str]):
712-
"""This parameter is only used by the Verify Auth Challenge Response Lambda trigger.
713-
This parameter should contain all of the information that is required to validate the user's
712+
"""This parameter is only used by the "Verify Auth Challenge" Response Lambda trigger.
713+
This parameter should contain all the information that is required to validate the user's
714714
response to the challenge. In other words, the publicChallengeParameters parameter contains the
715715
question that is presented to the user and privateChallengeParameters contains the valid answers
716716
for the question."""
@@ -730,7 +730,7 @@ class CreateAuthChallengeTriggerEvent(BaseTriggerEvent):
730730
"""Create Auth Challenge Lambda Trigger
731731
732732
Amazon Cognito invokes this trigger after Define Auth Challenge if a custom challenge has been
733-
specified as part of the Define Auth Challenge trigger.
733+
specified as part of the "Define Auth Challenge" trigger.
734734
It creates a custom authentication flow.
735735
736736
Notes:
@@ -775,7 +775,7 @@ def challenge_answer(self) -> Any:
775775
@property
776776
def client_metadata(self) -> Optional[Dict[str, str]]:
777777
"""One or more key-value pairs that you can provide as custom input to the Lambda function that
778-
you specify for the verify auth challenge trigger."""
778+
you specify for the "Verify Auth Challenge" trigger."""
779779
return self["request"].get("clientMetadata")
780780

781781
@property

aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def aws_region(self) -> Optional[str]:
231231

232232
@property
233233
def dynamodb(self) -> Optional[StreamRecord]:
234-
"""The main body of the stream record, containing all of the DynamoDB-specific fields."""
234+
"""The main body of the stream record, containing all the DynamoDB-specific fields."""
235235
stream_record = self.get("dynamodb")
236236
return None if stream_record is None else StreamRecord(stream_record)
237237

aws_lambda_powertools/utilities/data_classes/s3_object_event.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_header_value(
8282
default_value: str, optional
8383
Default value if no value was found by name
8484
case_sensitive: bool
85-
Whether to use a case sensitive look up
85+
Whether to use a case-sensitive look up
8686
Returns
8787
-------
8888
str, optional
@@ -128,7 +128,7 @@ def creation_date(self) -> str:
128128
@property
129129
def mfa_authenticated(self) -> str:
130130
"""The value is true if the root user or IAM user whose credentials were used for the request also was
131-
authenticated with an MFA device; otherwise, false.."""
131+
authenticated with an MFA device; otherwise, false."""
132132
return self["mfaAuthenticated"]
133133

134134

aws_lambda_powertools/utilities/data_classes/sqs_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def data_type(self) -> str:
7676

7777
class SQSMessageAttributes(Dict[str, SQSMessageAttribute]):
7878
def __getitem__(self, key: str) -> Optional[SQSMessageAttribute]: # type: ignore
79-
item = super(SQSMessageAttributes, self).get(key)
79+
item = super().get(key)
8080
return None if item is None else SQSMessageAttribute(item) # type: ignore
8181

8282

0 commit comments

Comments
 (0)