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

Remove pydantic upper bound #189

Merged
merged 26 commits into from
Dec 7, 2023
Merged

Remove pydantic upper bound #189

merged 26 commits into from
Dec 7, 2023

Conversation

antonymilne
Copy link
Contributor

@antonymilne antonymilne commented Dec 1, 2023

Description

Currently we have pydantic<2, which is not ideal for compatibility with other tools. It's easy to remove this so long as we make sure to always do pydantic imports using the following sort of pattern:

try:
    from pydantic.v1 import Field validator
except ImportError:  # pragma: no cov
    from pydantic import Field, validator

We are still using the pydantic v1 API everywhere and so nothing else changes. At some point in the future we should switch fully to v2 but that is a bigger project (and would make us incompatible with kedro-viz, which currently pins pydantic<2).

The changes have been made across vizro-core and vizro-ai.

As a nice bonus I've been able to remove a lot of the pydantic-mypy ignores.

I've refactored the test jobs quite a bit and made a new one that tests the lower bound pydantic==1.10.13. All other test jobs will pip install the latest compatible requirements, which would now be pydantic 2.5.2. @l0uden has also added new tests to the qa repo to test the lower bound.

So basically if you forget to do the imports correctly, tests should catch it so long as we have good test coverage 🤞

Checklist

  • I have not referenced individuals, products or companies in any commits, directly or indirectly
  • I have not added data or restricted code in any commits, directly or indirectly
  • I have updated the docstring of any public function/class/model changed
  • I have added tests to cover my changes (if applicable)

Types of changes

  • Docs/refactoring (non-breaking change which improves codebase)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

@antonymilne antonymilne requested a review from petar-qb December 6, 2023 22:19
Copy link
Contributor

@huong-li-nguyen huong-li-nguyen left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@antonymilne antonymilne merged commit 3a6ca7d into main Dec 7, 2023
34 checks passed
@antonymilne antonymilne deleted the dev/pydantic-v2 branch December 7, 2023 16:43
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.

6 participants