You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using AWS Lambda Powertools with Python type hints, the SQSEvent class is properly exported and can be imported directly from aws_lambda_powertools.utilities.data_classes.
However, SQSRecord - which is closely related to SQSEvent - is only available from the internal module:
While this works, it creates an inconsistent developer experience when working with SQS events since:
SQSEvent can be imported from the main module
SQSRecord must be imported from the internal submodule
This inconsistency forces developers to know the internal package structure rather than having a clean, intuitive API.
Code snippet
# Current approach requires two different import styles:fromaws_lambda_powertools.utilities.data_classesimportSQSEventfromaws_lambda_powertools.utilities.data_classes.sqs_eventimportSQSRecorddeflambda_handler(event, context):
sqs_event=SQSEvent(event)
forrecordinsqs_event.records:
process_sqs_record(record)
defprocess_sqs_record(record: SQSRecord) ->None:
message_data=json.loads(record.body)
# Processing logic...# Proposed approach would allow consistent imports:fromaws_lambda_powertools.utilities.data_classesimportSQSEvent, SQSRecord# Currently not possibledeflambda_handler_improved(event, context):
sqs_event=SQSEvent(event)
forrecordinsqs_event.records:
process_sqs_record_improved(record)
defprocess_sqs_record_improved(record: SQSRecord) ->None:
message_data=json.loads(record.body)
# Processing logic...
Possible Solution
Export SQSRecord in the aws_lambda_powertools.utilities.data_classes module by adding it to the __all__ list or by explicitly exporting it in the __init__.py file.
Suggested implementation:
In aws_lambda_powertools/utilities/data_classes/__init__.py:
fromaws_lambda_powertools.utilities.data_classes.sqs_eventimportSQSEvent, SQSRecord__all__= [
...,
"SQSEvent",
"SQSRecord", # Add this line
...
]
This small change would improve developer experience by allowing more consistent and intuitive imports when working with SQS events.
The text was updated successfully, but these errors were encountered:
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
AlisonVilela
changed the title
SQSRecord not exported in data_classes module
Enhancement: Export SQSRecord in main data_classes module
May 9, 2025
AlisonVilela
added a commit
to AlisonVilela/powertools-lambda-python
that referenced
this issue
May 9, 2025
Static type checker used
mypy (project's standard)
AWS Lambda function runtime
3.12
Powertools for AWS Lambda (Python) version
latest
Static type checker info
When using AWS Lambda Powertools with Python type hints, the SQSEvent class is properly exported and can be imported directly from aws_lambda_powertools.utilities.data_classes.
However, SQSRecord - which is closely related to SQSEvent - is only available from the internal module:
While this works, it creates an inconsistent developer experience when working with SQS events since:
This inconsistency forces developers to know the internal package structure rather than having a clean, intuitive API.
Code snippet
Possible Solution
Export SQSRecord in the aws_lambda_powertools.utilities.data_classes module by adding it to the
__all__
list or by explicitly exporting it in the__init__.py
file.Suggested implementation:
In
aws_lambda_powertools/utilities/data_classes/__init__.py
:This small change would improve developer experience by allowing more consistent and intuitive imports when working with SQS events.
The text was updated successfully, but these errors were encountered: