Closed
Description
Expected Behaviour
This is a bit of a nitpick but something I noticed on my travels...
child_exceptions
parameter is typed Optional[List[ExceptionInfo]]
but the None
case isn't handled anywhere before iteration over the attribute occurs in format_exceptions()
method.
Current Behaviour
Instantiating the exception and calling format_exceptions()
without providing a list for the child_exceptions
param will raise an exception.
Code snippet
from aws_lambda_powertools.utilities.batch.exceptions import BaseBatchProcessingError
err = BaseBatchProcessingError(msg="something") # types ok
err.format_exceptions("parent exception string")
Possible Solution
Most likely just make sure attrib is always a list without having to change the signature of the class.
class BaseBatchProcessingError(Exception):
def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = None):
...
self.child_exceptions = child_exceptions or []
Steps to Reproduce
See code snippet above.
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
No response