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

feat: add support for Pydantic V2 #227

Merged

Conversation

ruicaridade
Copy link
Contributor

Description

As it stands, any project using lago-python-client can't upgrade to Pydantic V2 due to version constraints. Fortunately for us, Pydantic V2 ships with V1 to allow for incremental adoption, which allows us to support both V1 and V2 without fundamentally changing the package's code:

try:
    from pydantic.v1 import BaseModel 
except ImportError:
    from pydantic import BaseModel

In addition to this, I changed all the from pydantic import BaseModel imports to pull from base_model instead.

Type of Change

Feature - non-breaking change

Testing

Used pytest to run the tests once for each version. To replicate:

  1. Install the project's base dependencies (in a virtualenv ideally).
pip install -e .
  1. Install Pydantic V1.
pip install pydantic==1.10
  1. Run pytest.
pytest
  1. Install Pydantic V2.
pip uninstall pydantic && pip install pydantic==2.6.1
  1. Run pytest again.
pytest

feat: add support for pydantic v2 backwards compatible import

misc: update install requirements allow pydantic v2.*

feat: update BaseModel imports
@ruicaridade ruicaridade changed the title Add support for Pydantic V2 feat: add support for Pydantic V2 Feb 13, 2024
@jdenquin jdenquin self-assigned this Feb 13, 2024
@vincent-pochet vincent-pochet merged commit 1695f71 into getlago:main Feb 13, 2024
5 checks passed
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.

3 participants