Skip to content

Bug: Pydantic deprecated methods are still used #5127

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
ascopes opened this issue Sep 5, 2024 · 4 comments
Closed

Bug: Pydantic deprecated methods are still used #5127

ascopes opened this issue Sep 5, 2024 · 4 comments
Assignees
Labels
dependencies Pull requests that update a dependency file

Comments

@ascopes
Copy link
Contributor

ascopes commented Sep 5, 2024

Expected Behaviour

Deprecated APIs should not be used.

Current Behaviour

/path/to/my/project/.venv/lib/python3.12/site-packages/pydantic/main.py:1132: PydanticDeprecatedSince20: The `parse_obj` method is deprecated; use `model_validate` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/
    warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Code snippet

from aws_lambda_powertools.utilities.parser import event_parser
from aws_lambda_powertools.utilities.typing import LambdaContext
from pydantic import BaseModel

class Ping(BaseModel):
    message: str


@event_parser(model=Ping)
def lambda_handler(event: Ping, _: LambdaContext) -> None:
    print(event.message)

Possible Solution

Update aws_lambda_powertools internals to use model_validate rather than parse_obj if Pydantic v2 is in use.

Steps to Reproduce

N/A

Powertools for AWS Lambda (Python) version

aws_lambda_powertools-2.43.1-py3-none-any.whl sha256:48116250c1771c7b8d4977ad2d475271074d86964107ccfd3fc6775e51984d88

AWS Lambda function runtime

3.12

Packaging format used

Lambda Layers

Debugging logs

No response

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

boring-cyborg bot commented Sep 5, 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

Hi @ascopes! Thanks for opening this issue! Yes, we are aware of this and are about to release the major version of Powertools - V3, where we will remove Pydantic v1 and only support Pydantic v2 with non-deprecated methods.

#4189

@leandrodamascena leandrodamascena self-assigned this Sep 5, 2024
@leandrodamascena leandrodamascena added dependencies Pull requests that update a dependency file and removed bug Something isn't working triage Pending triage from maintainers labels Sep 5, 2024
@leandrodamascena leandrodamascena moved this from Triage to Backlog in Powertools for AWS Lambda (Python) Sep 5, 2024
@leandrodamascena
Copy link
Contributor

I'm closing this issue. Please reopen if needed.

Copy link
Contributor

github-actions bot commented Sep 5, 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.

@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
dependencies Pull requests that update a dependency file
Projects
Development

No branches or pull requests

2 participants