Skip to content

Commit 3876721

Browse files
author
Tom McCarthy
committed
chore: readability improvements
1 parent 359151c commit 3876721

File tree

1 file changed

+3
-4
lines changed
  • aws_lambda_powertools/utilities/idempotency/persistence

1 file changed

+3
-4
lines changed

aws_lambda_powertools/utilities/idempotency/persistence/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def status(self) -> str:
8282
"""
8383
if self.is_expired:
8484
return STATUS_CONSTANTS["EXPIRED"]
85-
86-
if self._status in STATUS_CONSTANTS.values():
85+
elif self._status in STATUS_CONSTANTS.values():
8786
return self._status
8887
else:
8988
raise IdempotencyInvalidStatusError(self._status)
@@ -222,7 +221,7 @@ def _validate_payload(self, lambda_event: Dict[str, Any], data_record: DataRecor
222221
"""
223222
if self.payload_validation_enabled:
224223
lambda_payload_hash = self._get_hashed_payload(lambda_event)
225-
if not data_record.payload_hash == lambda_payload_hash:
224+
if data_record.payload_hash != lambda_payload_hash:
226225
raise IdempotencyValidationError("Payload does not match stored record for this event key")
227226

228227
def _get_expiry_timestamp(self) -> int:
@@ -263,7 +262,7 @@ def _save_to_cache(self, data_record: DataRecord):
263262
def _retrieve_from_cache(self, idempotency_key: str):
264263
cached_record = self._cache.get(idempotency_key)
265264
if cached_record:
266-
if all((not cached_record.is_expired, not cached_record.status == "INPROGRESS")):
265+
if not cached_record.is_expired:
267266
return cached_record
268267
logger.debug(f"Removing expired local cache record for idempotency key: {idempotency_key}")
269268
self._delete_from_cache(idempotency_key)

0 commit comments

Comments
 (0)