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

Add legacy pydantic v1 support #94

Merged
merged 6 commits into from
Feb 11, 2024
Merged

Add legacy pydantic v1 support #94

merged 6 commits into from
Feb 11, 2024

Conversation

ursereg
Copy link
Contributor

@ursereg ursereg commented Jan 30, 2024

Add support for old pydantic v1 models, so both versions of pydantic can be used with same version of erdantic.

Not sure how much it is useful for everybody (all pydantic v1 models will hopefully go away at some point), but it is useful for us now :)

Basically a copy of 0.51 implementation in separate file importing pydantic.v1 namespace, which is wrong because its copy paste, and good because it can be easily removed later.

@jayqi
Copy link
Member

jayqi commented Feb 1, 2024

Hi @ursereg, can you please clarify why you need this? In order to use erdantic, it needs to be installed in the same virtual environment as pydantic, so that it can import and analyze a Pydantic model within a running Python process. I don't believe you can have Pydantic v1 and Pydantic v2 installed simultaneously under normal circumstances.

@ursereg
Copy link
Contributor Author

ursereg commented Feb 1, 2024

Hi @ursereg, can you please clarify why you need this? In order to use erdantic, it needs to be installed in the same virtual environment as pydantic, so that it can import and analyze a Pydantic model within a running Python process. I don't believe you can have Pydantic v1 and Pydantic v2 installed simultaneously under normal circumstances.

Hi @jayqi

Yes you can have both versions, with installation of pydantic v2 there is pydantic.v1 namespace available, as described here: https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features

As to why I need it - I have some versioned API which new version uses v2, and old versions use v1 and for time being I need to keep it that way, and I use those multiple versions in same application (in same venv). I understand why this might not a normal use case and I am happy to just use my fork, just wanted to share back.

Copy link

codecov bot commented Feb 10, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (777eb3c) 97.5% compared to head (0a13367) 96.7%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main     #94     +/-   ##
=======================================
- Coverage   97.5%   96.7%   -0.8%     
=======================================
  Files         13      14      +1     
  Lines        534     591     +57     
=======================================
+ Hits         521     572     +51     
- Misses        13      19      +6     
Files Coverage Δ
erdantic/__init__.py 100.0% <100.0%> (ø)
erdantic/pydantic1.py 89.2% <89.2%> (ø)

@jayqi jayqi merged commit b2f945b into drivendataorg:main Feb 11, 2024
14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants