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

[DRAFT] [REFACTOR] Upgrade Pydantic to v2 #5508

Closed
wants to merge 3 commits into from

Conversation

jfcalvo
Copy link
Member

@jfcalvo jfcalvo commented Sep 18, 2024

Description

This is a draft to make visible the changes that we are doing in order to update Pydantic to v2.

Test suite progress:

  1. ==== 402 failed, 897 passed, 17 skipped, 1582 warnings in 189.12s (0:03:09) ====
  2. ==== 207 failed, 1092 passed, 17 skipped, 1640 warnings in 186.83s (0:03:06) ====

Refs #4935

Type of change

  • Refactor (change restructuring the codebase without changing functionality)

How Has This Been Tested

Checklist

  • I added relevant documentation
  • I followed the style guidelines of this project
  • I did a self-review of my code
  • I made corresponding changes to the documentation
  • I confirm My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

@jfcalvo jfcalvo closed this Nov 19, 2024
@jfcalvo jfcalvo deleted the refactor/upgrade-to-pydantic-v2 branch November 19, 2024 13:01
jfcalvo added a commit that referenced this pull request Nov 20, 2024
# Description
<!-- Please include a summary of the changes and the related issue.
Please also include relevant motivation and context. List any
dependencies that are required for this change. -->

An alternative work of pydantic v2 upgrade with the latest changes from
develop.

The main problems I found:
- The Optional values are now required. This will affect how schemas are
returned since default values are sets, including them as part of the
schema result (record without responses or suggestions, for example)
- I found some serialization errors when the response body (an error)
contains a ValueError object. The same is working with pydantic <2
- Automatic type conversion is not working anymore. This means that many
client requests may fail ( values are not automatically converted to
str, or some complex structures (record fields may be affected by this).
We can still define custom model_validators, but we must apply them
carefully.


Closes #4935


Refs #5508

**Type of change**
<!-- Please delete options that are not relevant. Remember to title the
PR according to the type of change -->

- Refactor (change restructuring the codebase without changing
functionality)

**How Has This Been Tested**
<!-- Please add some reference about how your feature has been tested.
-->

**Checklist**
<!-- Please go over the list and make sure you've taken everything into
account -->

- I added relevant documentation
- I followed the style guidelines of this project
- I did a self-review of my code
- I made corresponding changes to the documentation
- I confirm My changes generate no new warnings
- I have added tests that prove my fix is effective or that my feature
works
- I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)

---------

Co-authored-by: José Francisco Calvo <[email protected]>
Co-authored-by: José Francisco Calvo <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

1 participant