11
11
import sys
12
12
from abc import ABC , abstractmethod
13
13
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
15
15
16
16
from aws_lambda_powertools .shared import constants
17
17
from aws_lambda_powertools .utilities .batch .exceptions import (
18
18
BatchProcessingError ,
19
19
ExceptionInfo ,
20
20
)
21
- from aws_lambda_powertools .utilities .batch .types import BatchTypeModels
21
+ from aws_lambda_powertools .utilities .batch .types import BatchTypeModels , PartialItemFailureResponse , PartialItemFailures
22
22
from aws_lambda_powertools .utilities .data_classes .dynamo_db_stream_event import (
23
23
DynamoDBRecord ,
24
24
)
@@ -220,7 +220,7 @@ def failure_handler(self, record, exception: ExceptionInfo) -> FailureResponse:
220
220
221
221
222
222
class BasePartialBatchProcessor (BasePartialProcessor ): # noqa
223
- DEFAULT_RESPONSE : Dict [ str , List [ Optional [ dict ]]] = {"batchItemFailures" : []}
223
+ DEFAULT_RESPONSE : PartialItemFailureResponse = {"batchItemFailures" : []}
224
224
225
225
def __init__ (self , event_type : EventType , model : Optional ["BatchTypeModels" ] = None ):
226
226
"""Process batch and partially report failed items
@@ -239,7 +239,7 @@ def __init__(self, event_type: EventType, model: Optional["BatchTypeModels"] = N
239
239
"""
240
240
self .event_type = event_type
241
241
self .model = model
242
- self .batch_response = copy .deepcopy (self .DEFAULT_RESPONSE )
242
+ self .batch_response : PartialItemFailureResponse = copy .deepcopy (self .DEFAULT_RESPONSE )
243
243
self ._COLLECTOR_MAPPING = {
244
244
EventType .SQS : self ._collect_sqs_failures ,
245
245
EventType .KinesisDataStreams : self ._collect_kinesis_failures ,
@@ -253,7 +253,7 @@ def __init__(self, event_type: EventType, model: Optional["BatchTypeModels"] = N
253
253
254
254
super ().__init__ ()
255
255
256
- def response (self ):
256
+ def response (self ) -> PartialItemFailureResponse :
257
257
"""Batch items that failed processing, if any"""
258
258
return self .batch_response
259
259
@@ -294,7 +294,7 @@ def _has_messages_to_report(self) -> bool:
294
294
def _entire_batch_failed (self ) -> bool :
295
295
return len (self .exceptions ) == len (self .records )
296
296
297
- def _get_messages_to_report (self ) -> List [Dict [ str , str ] ]:
297
+ def _get_messages_to_report (self ) -> List [PartialItemFailures ]:
298
298
"""
299
299
Format messages to use in batch deletion
300
300
"""
0 commit comments