Closed
Description
Expected Behaviour
I'm using ApiGatewayResolver
without enabling validation and it shouldn't import Pydantic. Even if a customer has Pydantic installed, they should not import Pydantic without explicitly enabling validation: app = ApiGatewayResolver(enable_validation=True)
Current Behaviour
Profiling the application with tuna, I can see Pydantic being imported:
Code snippet
from aws_lambda_powertools.event_handler import ApiGatewayResolver
app = ApiGatewayResolver(enable_validation=False)
def lambda_handler(event, context):
return app.resolve(event, context)
requirements.txt
aws-lambda-powertools==2.27.0
aws-xray-sdk==2.12.1
botocore==1.32.3
fastjsonschema==2.19.0
jmespath==1.0.1
pydantic==1.10.13
python-dateutil==2.8.2
six==1.16.0
tuna==0.5.11
typing_extensions==4.8.0
urllib3==2.0.7
wrapt==1.16.0
Possible Solution
Move these imports to an standalone file or import them only when enable_validation is True.
Steps to Reproduce
1 - Create a file
2 - pip install aws-lambda-powertools[all] tuna
3 - Use the code snippet provided
4 - python -X importtime test.py 2> prof1.log
5 - tuna prof1.log
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
PyPi
Debugging logs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped