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

New command line flag -add-v1-to-imports #1986

Open
mattholden opened this issue Jun 3, 2024 · 0 comments
Open

New command line flag -add-v1-to-imports #1986

mattholden opened this issue Jun 3, 2024 · 0 comments

Comments

@mattholden
Copy link

Is your feature request related to a problem? Please describe.
Because Pydantic2 broke... everything, my org still uses Pydantic 1 until everything can be refactored. Because Pydantic 2 had all the breaking changes, they left the legacy package in the new "pydantic.v1" package inside the current deploy to allow for more piecemeal migrations rather than "all-or-nothing." So, I can change all my imports from "from pydantic.xxx" to "from pydantic.v1.xxx" and they will work without breaking even if I pull in the 2.x Pydantic library, allowing me to slowly migrate as I can.

However, that change in import statement is not captured in my generated models from DMCG, so they fail imports for classes like the field types at runtime.

Describe the solution you'd like
A new command line option "-add-v1-to-imports" that literally just changes "from pydantic" to "from pydantic.v1" in generated models for backward compatibility.

Describe alternatives you've considered
I considered writing a manual post-processor for generated files.

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

1 participant