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

[BACKPORT] #238 to 0.4.latest (Pydantic 2 Support) #240

Merged
merged 5 commits into from
Jan 3, 2024

Conversation

QMalcolm
Copy link
Collaborator

@QMalcolm QMalcolm commented Jan 3, 2024

This is a backport of #238 to 0.4.latest. The commits included in this PR were cherry-picked from commits added to main from #238. No changes were made, there were no merge conflicts.

We are going to need to support pydantic 1 for some time. We think currently
that we'll have to support it for atleast another year. However, we also
need to begin supporting pydantic 2. Thus we need this shim to have the
flexibility of supporting both.

I have also run `hatch build` and ensured that this shim _does_ get included
in the resulting tarball. In the upcoming commits, we'll switch over direct
pydantic imports to instead use this shim, and then loosen the version in the
pyproject config.
This is necessary because the typing for v1 stuff breaks when using
Pydantic 2. We can stop doing this once we actually migrate off of
Pydantic 1 implementations.
@cla-bot cla-bot bot added the cla:yes label Jan 3, 2024
@QMalcolm QMalcolm changed the title [BACKPORT] #238 to 0.4.latest [BACKPORT] #238 to 0.4.latest (Pydantic 2 Support) Jan 3, 2024
@QMalcolm QMalcolm requested review from MichelleArk and tlento January 3, 2024 18:48
Copy link

@MichelleArk MichelleArk left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Thinking out loud through any potential risk given this is a backport:
The change is quite safe and backwards-compatible. The only risk I could imagine is if 0.4 users start installing pydantic 2.0 and the downgrade path via pydantic.v1/pydantic_shim isn't exactly 1:1 with pydantic v1.

But given pydantic.v1 is documented for this very purpose, I'd be surprised if that were the case! Additionally, given the additional testing you've added to run against both major pydantic versions, it feels like we've mitigated this risk sufficiently 👍

@QMalcolm
Copy link
Collaborator Author

QMalcolm commented Jan 3, 2024

@MichelleArk there is some internal risk. The only thing dbt-core uses pydantic for out of the box is the production of the semantic manifest. I plan to address this risk by releasing a 0.4.3dev0 version of DSI and manually testing that an pydantic 1 and a pydantic 2 core environment produce the same semantic manifest.

For the open source community there should be essentially zero risk. All this will be is a quality of life improvement for them. As it will allow people using pydantic 2 and stuck on dbt-core to upgrade to dbt-core 1.7 and it'll allow people who are on dbt-core 1.7 who want to migrate off of pydantic 1 to pydantic 2 to finally do so.

@QMalcolm QMalcolm merged commit 653a177 into 0.4.latest Jan 3, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants