-
Notifications
You must be signed in to change notification settings - Fork 421
feat(parser): add support for Pydantic v2 #2733
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
feat(parser): add support for Pydantic v2 #2733
Conversation
hooorraay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a requirements.txt
git+....
pydantic>=2
and poetry command to add this dep for customers to test
Hi Powertools customers and community at large! We have the PR for Pydanticv2 ready for testing and would love to hear your feedback. Our goal is to merge this PR on July 21st and it would be nice to hear something before then. Tagging people we know are directly interested in this support: @ran-isenberg @djfurman @half2me @wurstnase @taharah @wickeat @waveFrontSet |
Signed-off-by: Cavalcante Damascena <lcdama@b0be8355743f.ant.amazon.com>
Signed-off-by: Cavalcante Damascena <lcdama@b0be8355743f.ant.amazon.com>
Hi @waveFrontSet, can you test again? |
Hi @leandrodamascena, updated to commit
|
Hi @waveFrontSet! I could reproduce the problem in my local environment and fixed it. Can you check again? Thank you. |
Hi @leandrodamascena, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superb work Leandro! The only concern I have is that we are calling "disable_pydantic_v2_warning" in so many different places, and I wonder if we could improve performance by memoizing it so it only runs once, no matter how many times it gets called. What do you think?
Signed-off-by: Cavalcante Damascena <lcdama@b0be8355743f.ant.amazon.com>
Signed-off-by: Cavalcante Damascena <lcdama@b0be8355743f.ant.amazon.com>
Signed-off-by: Cavalcante Damascena <lcdama@b0be8355743f.ant.amazon.com>
Signed-off-by: Cavalcante Damascena <lcdama@b0be8355743f.ant.amazon.com>
Kudos, SonarCloud Quality Gate passed! |
Issue number: #2672
Additional issue: #2427
Summary
Changes
After an extensive week of investigation, experimentation, and implementation, I'm excited to open this pull request, which introduces support for Pydantic v2 in the parser feature. I wanted to provide you with an overview of the changes and considerations made during this process:
Support for Pydantic v1 and v2:
Powertools and the support for Pydantic:
No-breaking changes were made
NOTE: We haven't detected any breaking changes, but please let us know as soon as possible if you find any.
Compatibility table
PydanticDeprecatedSince20
andPydanticDeprecationWarning
warnings (related to these functions). This allows existing applications to continue functioning as expected without outputting warnings.How to test before we merge this PR
To facilitate the testing of Pydantic v2 before merging this pull request, we have created a separate branch called
poc/pydanticv2
where you can find the relevant code changes. Here are the steps to follow in order to test it effectively:If using sourcecode:
- Clone Powertools repository
- Fetch the
poc/pydanticv2
branch- Check out the branch locally by running the command:
git checkout poc/pydanticv2
.If using pip:
Create or modify the
requirements.txt
file and add the following content:Then install by running:
pip install -r requirements.txt
.If using Poetry:
poetry add git+https://github.com/aws-powertools/powertools-lambda-python#poc/pydanticv2 poetry add pydantic>2
Note for documentation
Since the Powertools currently relies on Pydantic v1 as its official dependency, you need to change the
aws-lambda-powertools[tracer]
oraws-lambda-powertools[all]
installation toaws-lambda-powertools
oraws-lambda-powertools[validation,tracer,aws-sdk]
and add Pydantic v2 as an extra dependency.Missing in this PR
User experience
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.