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

Support for gradual migration of Pydantic V1 -> V2 #274

Open
Strryke opened this issue Mar 15, 2024 · 3 comments
Open

Support for gradual migration of Pydantic V1 -> V2 #274

Strryke opened this issue Mar 15, 2024 · 3 comments

Comments

@Strryke
Copy link

Strryke commented Mar 15, 2024

Hi! I'm migrating a big codebase over from pydantic v1 to v2 and my initial approach is to upgrade to V2 and then change all imports to import from pydantic.v1 and slowly migrate things over.

Kor is throwing an error for me for the from_pydantic function as it seems to look for which version of pydantic is installed and use that one accordingly. I'm wondering if there's any way to have V2 installed but make Kor use V1 instead? thanks!

Argument of type "type[SupportTicket]" cannot be assigned to parameter "model_class" of type "type[BaseModel]" in function "from_pydantic" "type[SupportTicket]" is incompatible with "type[BaseModel]"

@eyurtsev
Copy link
Owner

It's not very difficult to do, but not top priority for me right now. I'm happy tor review a PR for this change if you're interested.

How many pydantic classes do you have that are being fed into Kor?

@Strryke
Copy link
Author

Strryke commented Mar 17, 2024

Hey! i would be happy to open a PR for this change. my first thought would be to modify the _translate_pydantic_to_kor and from_pydantic function and allow it take take in a user's argument. let me know if this is a correct approach, thanks!

@eyurtsev
Copy link
Owner

It should be based on isinstance checks in the appropriate places instead of if checks on the pydantic major version.

All changes should be internal without any user facing API picking up additional variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants