Skip to content
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

patch: update deprecated core_schema function #722

Closed
wants to merge 1 commit into from

Conversation

sorXCode
Copy link

Purpose

This PR fixes some deprecation warnings while using Pydantic v2.

Context

There were deprecation warnings while running pytest in my PydanticV2 (2.4.1) project.

====================================== warnings summary ======================================
venv/lib/python3.10/site-packages/beanie/odm/fields.py:544
  venv/lib/python3.10/site-packages/beanie/odm/fields.py:544: DeprecationWarning: `general_plain_validator_function` is deprecated, use `with_info_plain_validator_function` instead.
    return core_schema.general_plain_validator_function(validate)

venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898
venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898
venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898
venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898
venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898
venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898
  venv/lib/python3.10/site-packages/pydantic_core/core_schema.py:3898: DeprecationWarning: `general_plain_validator_function` is deprecated, use `with_info_plain_validator_function` instead.
    warnings.warn(

venv/lib/python3.10/site-packages/beanie/odm/fields.py:123
venv/lib/python3.10/site-packages/beanie/odm/fields.py:123
venv/lib/python3.10/site-packages/beanie/odm/fields.py:123
venv/lib/python3.10/site-packages/beanie/odm/fields.py:123
venv/lib/python3.10/site-packages/beanie/odm/fields.py:123
  venv/lib/python3.10/site-packages/beanie/odm/fields.py:123: DeprecationWarning: `general_plain_validator_function` is deprecated, use `with_info_plain_validator_function` instead.
    python_schema=core_schema.general_plain_validator_function(

@roman-right
Copy link
Member

Thank you for the PR, I'll check it this week

@sorXCode
Copy link
Author

sorXCode commented Oct 8, 2023

@roman-right, I've fixed the pre-commit hook failure.
I also discovered that the general_plain_validator_function was deprecated and the new with_info_plain_validator_function introduced in Pydantic_core 2.10 (PR here, release here), whereas the GitHub Action in this repo uses Pydantic v2.3 (Pydantic_core 2.6.3), hence the failure.

What do you think could be done in this scenario? Perhaps adding an "if block" for Pydantic >2.3 is safe?

@roman-right
Copy link
Member

Thank you for the PR! I'll check it again and merge by the end of this week

@roman-right
Copy link
Member

It looks like it doesn't work with Pydantic V2 (Or should I update my gh-actions?)

@roman-right
Copy link
Member

It looks like this PR is not in work more. If no, feel free to open a new one.

@roman-right roman-right closed this Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants