diff --git a/aws_lambda_powertools/utilities/batch/exceptions.py b/aws_lambda_powertools/utilities/batch/exceptions.py index d541d18d18f..89659e42bf8 100644 --- a/aws_lambda_powertools/utilities/batch/exceptions.py +++ b/aws_lambda_powertools/utilities/batch/exceptions.py @@ -1,6 +1,8 @@ """ Batch processing exceptions """ +from __future__ import annotations + import traceback from types import TracebackType from typing import List, Optional, Tuple, Type @@ -9,10 +11,10 @@ class BaseBatchProcessingError(Exception): - def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = None): + def __init__(self, msg="", child_exceptions: List[ExceptionInfo] | None = None): super().__init__(msg) self.msg = msg - self.child_exceptions = child_exceptions + self.child_exceptions = child_exceptions or [] def format_exceptions(self, parent_exception_str): exception_list = [f"{parent_exception_str}\n"] @@ -27,7 +29,7 @@ def format_exceptions(self, parent_exception_str): class BatchProcessingError(BaseBatchProcessingError): """When all batch records failed to be processed""" - def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = None): + def __init__(self, msg="", child_exceptions: List[ExceptionInfo] | None = None): super().__init__(msg, child_exceptions) def __str__(self):