-
Notifications
You must be signed in to change notification settings - Fork 421
Bug: Pydantic "escape hatch" no longer available #5352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
For reference, I was trying to import from aws_lambda_powertools.utilities.parser import computed_field is not a valid import. |
Hey @areifert thanks a lot for opening this issue! In fact we are not exporting Pydantic objects from parser and we explain that in our upgrade guide to v3. In Powertools v3 we have dropped support for Pydantic v1 and are only supporting Pydantic v2 which is why we are no longer exporting pydantic types directly and allowing customers to import them directly from Pydantic. First, I must say that I agree with that we need to update our documentation and we are already doing this. I'll try to merge this PR as soon as possible to prevent this type of error. Let me explain some reasons why we removed this export: 1 - Pydantic V2 was a complete refactoring of the Pydantic project and they made several changes including, but not limited, to the way they export types, classes, methods, and others. If we continue to expose them directly from Powertools and some export in Pydantic has changed, our customers may get the impression that there is some bug in Powertools and that is not the experience we want to have for our customers. 2 - The way we were doing this was by exposing everything exposed from pydantic to our customers, but there is a long discussion in the Pydantic repository about how pydantic/pydantic#6748 when importing and loading things in this new version. We don't want our customers to inadvertently import everything from Pydantic and this could create some slowdown in their functions. Can you please try importing them directly from Pydantic? |
@leandrodamascena: this is perfect, thanks for the detailed response. I was able to import It looks like some Pydantic exports are still available from (P.S.: I've been using Powertools for only a month or two and am really enjoying it, thanks for all you do!) |
This is expected because now we just export
Hey, that's awesome to hear! We're here to support you in any way you need. Feel free to open an issue or talk to us on our Discord server https://discord.gg/B8zZKbbyET Closing this issue. |
|
Expected Behaviour
The Parser documentation FAQ states that an "escape hatch" mechanism can be used to access imports from the base
pydantic
library that are not otherwise available as imports fromaws_lambda_powertools.utilities.parser
: https://docs.powertools.aws.dev/lambda/python/latest/utilities/parser/#faq.Current Behaviour
aws_lambda_powertools.utilities.parser.pydantic
is not a valid import path. (This may have been an older feature that has since been removed.)Code snippet
from aws_lambda_powertools.utilities.parser.pydantic import <what you'd like to import'>
Possible Solution
If all
pydantic
imports can be made available ataws_lambda_powertools.utilities.parser.pydantic
(likely by modifying aws_lambda_powertools/utilities/parser/__init__.py), that would be ideal. Otherwise, the documentation should be updated to remove this feature.Steps to Reproduce
Attempting to import anything from
aws_lambda_powertools.utilities.parser.pydantic
will result in an import error.Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
Lambda Layers
Debugging logs
No response
The text was updated successfully, but these errors were encountered: