Skip to content

Commit 2cac2b5

Browse files
refactor(batch): type response() method (#3023)
Co-authored-by: Leandro Damascena <[email protected]>
1 parent 23a9ad3 commit 2cac2b5

File tree

1 file changed

+6
-6
lines changed
  • aws_lambda_powertools/utilities/batch

1 file changed

+6
-6
lines changed

aws_lambda_powertools/utilities/batch/base.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import sys
1212
from abc import ABC, abstractmethod
1313
from enum import Enum
14-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload
14+
from typing import Any, Callable, List, Optional, Tuple, Union, overload
1515

1616
from aws_lambda_powertools.shared import constants
1717
from aws_lambda_powertools.utilities.batch.exceptions import (
1818
BatchProcessingError,
1919
ExceptionInfo,
2020
)
21-
from aws_lambda_powertools.utilities.batch.types import BatchTypeModels
21+
from aws_lambda_powertools.utilities.batch.types import BatchTypeModels, PartialItemFailureResponse, PartialItemFailures
2222
from aws_lambda_powertools.utilities.data_classes.dynamo_db_stream_event import (
2323
DynamoDBRecord,
2424
)
@@ -220,7 +220,7 @@ def failure_handler(self, record, exception: ExceptionInfo) -> FailureResponse:
220220

221221

222222
class BasePartialBatchProcessor(BasePartialProcessor): # noqa
223-
DEFAULT_RESPONSE: Dict[str, List[Optional[dict]]] = {"batchItemFailures": []}
223+
DEFAULT_RESPONSE: PartialItemFailureResponse = {"batchItemFailures": []}
224224

225225
def __init__(self, event_type: EventType, model: Optional["BatchTypeModels"] = None):
226226
"""Process batch and partially report failed items
@@ -239,7 +239,7 @@ def __init__(self, event_type: EventType, model: Optional["BatchTypeModels"] = N
239239
"""
240240
self.event_type = event_type
241241
self.model = model
242-
self.batch_response = copy.deepcopy(self.DEFAULT_RESPONSE)
242+
self.batch_response: PartialItemFailureResponse = copy.deepcopy(self.DEFAULT_RESPONSE)
243243
self._COLLECTOR_MAPPING = {
244244
EventType.SQS: self._collect_sqs_failures,
245245
EventType.KinesisDataStreams: self._collect_kinesis_failures,
@@ -253,7 +253,7 @@ def __init__(self, event_type: EventType, model: Optional["BatchTypeModels"] = N
253253

254254
super().__init__()
255255

256-
def response(self):
256+
def response(self) -> PartialItemFailureResponse:
257257
"""Batch items that failed processing, if any"""
258258
return self.batch_response
259259

@@ -294,7 +294,7 @@ def _has_messages_to_report(self) -> bool:
294294
def _entire_batch_failed(self) -> bool:
295295
return len(self.exceptions) == len(self.records)
296296

297-
def _get_messages_to_report(self) -> List[Dict[str, str]]:
297+
def _get_messages_to_report(self) -> List[PartialItemFailures]:
298298
"""
299299
Format messages to use in batch deletion
300300
"""

0 commit comments

Comments
 (0)