Skip to content

Migrate to Pydantic v2#2695

Merged
ChrisLovering merged 5 commits into
mainfrom
pydantic-v2
Aug 11, 2023
Merged

Migrate to Pydantic v2#2695
ChrisLovering merged 5 commits into
mainfrom
pydantic-v2

Conversation

@ChrisLovering
Copy link
Copy Markdown
Member

@ChrisLovering ChrisLovering commented Jul 25, 2023

Summary

All commits starting with breaking: are breaking changes from Pydantic and will be squashed into 1 commit before merging. (Hence the do not merge tag)

Other commits are kaizen style commits that I noticed while working on this PR.

This will be far easier to review commit-by-commit.

Todo:

Squash commits before merging

@ChrisLovering ChrisLovering added a: dependencies Related to package dependencies and management p: 2 - normal Normal Priority review: do not merge The PR can be reviewed but cannot be merged now labels Jul 25, 2023
@shtlrs
Copy link
Copy Markdown
Contributor

shtlrs commented Jul 26, 2023

Required investigation
I have not investigated if @field_validator("", mode="before") works the same as @validator("", pre=True) as far as the "*" is concerned to run the validator on all fields. relevant commit: 46bf3cc

According to their docs, it looks like a wildcard will do the job.
image

@ChrisLovering
Copy link
Copy Markdown
Member Author

ChrisLovering commented Jul 26, 2023

According to their docs, it looks like a wildcard will do the job.

Ah nice, thanks.

@ChrisLovering ChrisLovering force-pushed the pydantic-v2 branch 3 times, most recently from 0c3a858 to a3128ba Compare July 31, 2023 16:59
@ChrisLovering ChrisLovering marked this pull request as ready for review July 31, 2023 16:59
@ChrisLovering ChrisLovering force-pushed the pydantic-v2 branch 2 times, most recently from 395b51d to 804925c Compare August 4, 2023 13:01
Copy link
Copy Markdown
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Copy Markdown
Contributor

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

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

Great work.

Would you like to do the same thing as 3a279b3 for Colours and Emojis, I don't think these are things that anyone will ever configure, i don't even see the use of configuring them. (Might as well look into other classes that we ourselves do not quite setup)

@ChrisLovering
Copy link
Copy Markdown
Member Author

Great work.

Would you like to do the same thing as 3a279b3 for Colours and Emojis, I don't think these are things that anyone will ever configure, i don't even see the use of configuring them. (Might as well look into other classes that we ourselves do not quite setup)

I didn't touch colours as it has the validator, but that just seems to convert hexstrings into ints, so that might be something we can move to a basic class. Emojis needs to stay he same way as it is, mostly for the trash & incidents emojis.

https://docs.pydantic.dev/latest/migration/#changes-to-handling-of-standard-types
> While union types will still attempt validation of each choice from left to right, they now preserve the type of the input whenever possible, even if the correct type is not the first choice for which the input would pass validation
@ChrisLovering ChrisLovering removed the review: do not merge The PR can be reviewed but cannot be merged now label Aug 11, 2023
@ChrisLovering ChrisLovering merged commit 14b0139 into main Aug 11, 2023
@ChrisLovering ChrisLovering deleted the pydantic-v2 branch August 11, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: dependencies Related to package dependencies and management p: 2 - normal Normal Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants