Skip to content

Bug: pydantic imports from aws_lambda_powertools.utilities.parser.pydantic no longer available #5249

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

Closed
RyanFrench opened this issue Sep 26, 2024 · 5 comments · Fixed by #5316
Assignees
Labels
documentation Improvements or additions to documentation not-a-bug

Comments

@RyanFrench
Copy link

Expected Behaviour

As per the documentation FAQ I would expect to be able to import X from pydantic to include types such as EmailStr

Current Behaviour

Currently in 3.0.0 we are unable to import pydantic types via the parser.

Code snippet

from aws_lambda_powertools.utilities.parser.pydantic import EmailStr

Possible Solution

Update documentation to include the recommended way to import X from pydantic, or implement the feature that was available in 2.X.

Steps to Reproduce

Try and import a pydantic type from aws_lambda_powertools.utilities.parser.pydantic, which no longer exists.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.11

Packaging format used

PyPi

Debugging logs

No response

@RyanFrench RyanFrench added bug Something isn't working triage Pending triage from maintainers labels Sep 26, 2024
Copy link

boring-cyborg bot commented Sep 26, 2024

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

@leandrodamascena
Copy link
Contributor

leandrodamascena commented Sep 26, 2024

Hey @RyanFrench, thanks for opening this issue to report this behavior.

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 your suggestion that we need to improve our documentation and upgrade guide to make it clear to customers, but I don't think we should revert this change for a few reasons:

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 v2 is slower than v1 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.

I will be sending a PR today to update our Upgrade Guide and documentation to clarify this change. I will ping you on this PR to get your feedback - if possible.

Thank you very much for bringing this up, I believe that improving our documentation will prevent other customers from having the same issue.

@leandrodamascena leandrodamascena added not-a-bug and removed bug Something isn't working triage Pending triage from maintainers labels Sep 26, 2024
@leandrodamascena leandrodamascena moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Sep 26, 2024
@leandrodamascena leandrodamascena self-assigned this Sep 26, 2024
@leandrodamascena leandrodamascena moved this from Working on it to Pending customer in Powertools for AWS Lambda (Python) Sep 26, 2024
@leandrodamascena leandrodamascena moved this from Pending customer to Working on it in Powertools for AWS Lambda (Python) Sep 26, 2024
@leandrodamascena leandrodamascena added the documentation Improvements or additions to documentation label Sep 26, 2024
@RyanFrench
Copy link
Author

Thank you, I assumed as much but wasn't sure what the new recommended way was to use other pydantic classes within the parser.

Copy link
Contributor

github-actions bot commented Oct 7, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Oct 7, 2024
Copy link
Contributor

github-actions bot commented Oct 8, 2024

This is now released under 3.1.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Oct 8, 2024
@leandrodamascena leandrodamascena moved this from Coming soon to Closed in Powertools for AWS Lambda (Python) Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation not-a-bug
Projects
3 participants