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

DM-40744: Convert to Pydantic v2 #855

Merged
merged 4 commits into from
Sep 18, 2023
Merged

DM-40744: Convert to Pydantic v2 #855

merged 4 commits into from
Sep 18, 2023

Conversation

rra
Copy link
Member

@rra rra commented Sep 14, 2023

Update to Pydantic v2 and remove all calls to deprecated methods.

This unfortunately requires two ugly workarounds, one due to a bug in Pydantic's mypy plugin and one due to a bug in FastAPI. For the first, a bunch of fields in TokenData that should be inherited from TokenUserInfo have to be reiterated because Pydantic's mypy plugin loses a union with None on inherited attributes. For the second, an exception handler for RequestValidationError had to be added to avoid FastAPI attempting to serialize PydanticUndefinedType when the user doesn't provide a query attribute that must be a list.

@rra rra force-pushed the tickets/DM-40744 branch 2 times, most recently from bb2c1cf to c37b054 Compare September 18, 2023 22:53
Update to Pydantic v2 and remove all calls to deprecated methods.
Use alpha releases of Safir and documenteer.

This unfortunately requires two ugly workarounds, one due to a bug
in Pydantic's mypy plugin and one due to a bug in FastAPI. For the
first, a bunch of fields in TokenData that should be inherited from
TokenUserInfo have to be reiterated because Pydantic's mypy plugin
loses a union with None on inherited attributes. For the second, an
exception handler for RequestValidationError had to be added to
avoid FastAPI attempting to serialize PydanticUndefinedType when the
user doesn't provide a query attribute that must be a list.
Pydantic v2 changed some of the doc cross-references that need to
be ignored.
The new Pydantic breaks sphinx-autodoc-typehints, and the latter
hasn't been fixed yet, so we have to ignore warnings for now because
there is one unfixable warning.
Some validators that were supposed to run before Pydantic parsing
were instead running after it, which cased test failures with the
Kubernetes operator. Fix those and add a better test for the
timedelta validator that we use.
@rra rra marked this pull request as ready for review September 18, 2023 23:07
@rra rra merged commit e8dccfe into main Sep 18, 2023
5 checks passed
@rra rra deleted the tickets/DM-40744 branch September 18, 2023 23:07
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.

None yet

1 participant