Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add v1 namespace #8

Merged
merged 4 commits into from
Oct 16, 2023
Merged

feat: add v1 namespace #8

merged 4 commits into from
Oct 16, 2023

Conversation

tlambert03
Copy link
Member

from pydantic_compat.v1 import BaseModel

alias for

try:
    from pydantic.v1 import *  # noqa
except ImportError:
    from pydantic import *  # type: ignore # noqa

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (c8b911b) 94.69% compared to head (c7bdd82) 94.73%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   94.69%   94.73%   +0.03%     
==========================================
  Files           8        9       +1     
  Lines         264      266       +2     
==========================================
+ Hits          250      252       +2     
  Misses         14       14              
Files Coverage Δ
src/pydantic_compat/__init__.py 100.00% <ø> (ø)
src/pydantic_compat/v1.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean... I wouldn't do the *, but fine. 😂

@jni
Copy link

jni commented Oct 16, 2023

I retract the * thing. 😂

@VolkerH
Copy link

VolkerH commented Oct 16, 2023

Wow. Thanks @tlambert03 ! Some backchannel communication happening there across 3 continents :-)

@@ -0,0 +1,5 @@
"""This module is a try/except wrapper the pydantic.v1 namespace."""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

around or that wraps the pydantic.v1 namespace ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, typo. will fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I elaborated it to this:

"""This module is a try/except pass-through for the pydantic.v1 namespace.

The pydantic.v1 namespace was added in pydantic v2. It contains the entire
pydantic v1 package. For packages that would like to unpin their 'pydantic<2'
dependency without needing to update all of their code to use the pydantic v2 api,
this provides a simple way to delay that update.

This is different from the goal of pydantic_compat on the whole, which is to provide
an API translation layer that allows you to actually use pydantic v2 features
(e.g. rust-backed speed, etc...) while also being compatible with packages that pin
pydantic<2.
"""

@tlambert03 tlambert03 merged commit 33b2662 into pyapp-kit:main Oct 16, 2023
@tlambert03 tlambert03 deleted the v1 branch October 16, 2023 13:20
tlambert03 added a commit to tlambert03/pydantic-compat that referenced this pull request Oct 19, 2023
tlambert03 added a commit that referenced this pull request Oct 24, 2023
* Revert "update readme"

This reverts commit 454df21.

* Revert "update readme"

This reverts commit a28d949.

* Revert "feat: add v1 namespace (#8)"

This reverts commit 33b2662.

* redo field stuff

* undo change
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants