-
Notifications
You must be signed in to change notification settings - Fork 428
Bug: Conflicting dependencies with Pydantic V2 #2926
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
Hello @barreeeiroo! Thank you for opening this issue! This is actually not a bug. We've kept Pydantic v1 as the default in Powertools to avoid issues with dependency resolutions for customers who are using Powertools with Pydantic v1 and don't want to switch to Pydantic v2. To add the use of Pydantic v2 with Powertools, you must remove the optional dependency for Pydantic. In you case you can change your file:
Reference: https://docs.powertools.aws.dev/lambda/python/latest/utilities/parser/#using-pydantic-v2 Thanks |
Hi @leandrodamascena, you're totally right. I've updated the As a possible improvement though, maybe the documentation regarding Pydantic V2 could be improved a little bit. I have already checked the link you mention before (Using Pydantic V2) and my assumption was that I "just" had to include the In the documentation, right below where it says "Add EDIT: requirements.txt should be:
|
|
Expected Behaviour
When defining a
requirements.txt
file with dependencies, it should be possible to define it like this:Running
pip install -r requirements.txt
should install bothaws-lambda-powertools
andpydantic
packages. AWS Lambda Powertools is compatible with Pydantic V2 thanks to #2733.Current Behaviour
Running
pip install -r requirements.txt
raises the following error:Code snippet
pip install -r requirements.txt
Possible Solution
I was surprised when finding this error because, based on #2672 and #2733, it seems like AWS Lambda Powertools was already compatible with Pydantic V2.
However, when looking at the
pyproject.toml
file I found out about the dependency being still in V1:Shouldn't this be set to be either
^1.8.2
or^2.0.3
(based on Pydantic V2 usage docs)?So, a possible solution could be:
Ideally, it would be nice to have something like
^1.8.2 || ^2.0.3
, but not sure if that's allowed in Poetry.Steps to Reproduce
requirements.txt
file.pip install -r requirements.txt
.Powertools for AWS Lambda (Python) version
2.22.0
AWS Lambda function runtime
3.11
Packaging format used
Lambda Layers, PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: