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

Migrate to Pydantic v2 #98

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

PaddyAlton
Copy link

@PaddyAlton PaddyAlton commented Oct 7, 2024

This will fix #97 - I encountered the same problems when I needed to upgrade to Pydantic v2 in my DBT project.

Two changes are required to effect the migration:

First, I have removed the import of PydanticValueError, which no longer exists. I don't think any special functionality was provided by this import, and my sense is that the Pydantic... errors are for their internal use (the errors codes are now hardwired into ErrorCodes, a Literal, and don't seem to encourage custom use as previously in dbt2looker. Therefore the custom error is now derived from ValueError and should produce the same output message if a specific adaptor is not supported.

Secondly, Optional fields are now handled differently. I have given a default value of None to all the ones that had no default value, which should be behaviour-preserving (value doesn't have to be supplied and doesn't have a 'special' default value).

I tested it on my own DBT project to verify that nothing unexpected happens.

IMPORTANT NOTE

Naturally I need to keep my own fork of the project operational. Therefore this PR is built on top of my stack of open PRs. It is the fourth in the stack. Reviewers should review only the most recent commit.

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.

Outdated Pydantic V1 functionality
1 participant