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
pydantic.v1.parse_obj_as internally uses pydantic.main.create_model instead of pydantic.v1.main.create_model #6361
Comments
`_get_parsing_type` in `pydantic.v1` was depending on `create_model` from `pydantic.main` instead of `pydantic.v1.main`. This causes the issue outlined here - pydantic#6361
Looks like this bug crept in because V1 code that is copied over to |
Fixed in 2c0e2a6 |
@hramezani when can I expect this to be released ? |
@SharathHuddar We are going to make a release today. |
@Kludex, once the fix is released, please let us know. |
@Kludex @hramezani, the issue still exists using the new version. Source code for the dependency: https://github.com/Azure/partnercenter-cli-extension/blob/main/partnercenter/setup.py#L39-L43 |
@jsntcy Based on the error picture that you posted, Your codebase is using
|
@hramezani, |
Also supports pydantic v1. pydantic v2 provides v1 api through `pydantic.v1` import, so we can support both versions by trying to import from `pydantic.v1` and fallback to old behaviour. See https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features. pydantic == 2.0.0 does not work due to pydantic/pydantic#6361, so we need to blacklist that specific version.
Also supports pydantic v1. pydantic v2 provides v1 api through `pydantic.v1` import, so we can support both versions by trying to import from `pydantic.v1` and fallback to old behaviour. See https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features. pydantic == 2.0.0 does not work due to pydantic/pydantic#6361, so we need to blacklist that specific version.
Initial Checks
main
branch, or equivalentDescription
I was trying to migrate my codebase from V1 to V2 (mostly by replacing
import pydantic
withimport pydantic.v1
) and noticed thatpydantic.v1.parse_obj_as
was not working as intended and was leading to the following error:On inspecting the source code, I noticed that
parse_obj_as
calls_get_parsing_type
which inturn callspydantic.main.create_model
instead ofpydantic.v1.main.create_model
The issue gets resolved on updating the import statement in
pydantic.v1.tools._get_parsing_type: 24
fromfrom pydantic.main import create_model
tofrom pydantic.v1.main import create_model
Example Code
No response
Python, Pydantic & OS Version
Selected Assignee: @lig
The text was updated successfully, but these errors were encountered: