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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lago_python_client/base_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from typing import Type

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel


class BaseClient(ABC):
Expand Down
5 changes: 4 additions & 1 deletion lago_python_client/base_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from pydantic import BaseModel
try:
from pydantic.v1 import BaseModel # type: ignore
except ImportError:
from pydantic import BaseModel


class BaseResponseModel(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/events/clients.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Any, ClassVar, Optional, Type

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_client import BaseClient
from ..fees.clients import FeeClient
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
except ImportError: # Python 3.7
from typing_extensions import Protocol # type: ignore

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .services.json import to_json
from .services.request import make_headers, make_url, send_delete_request, send_get_request, send_post_request, send_put_request
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/add_on.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/applied_coupon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .credit import CreditsResponse
from ..base_model import BaseResponseModel
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/billable_metric.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
4 changes: 2 additions & 2 deletions lago_python_client/models/charge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .tax import TaxesResponse
from ..base_model import BaseResponseModel
Expand Down Expand Up @@ -63,4 +63,4 @@ class ChargeOverrides(BaseModel):


class ChargesOverrides(BaseModel):
__root__: List[ChargeOverrides]
__root__: List[ChargeOverrides]
2 changes: 1 addition & 1 deletion lago_python_client/models/coupon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/credit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .invoice_item import InvoiceItemResponse
from ..base_model import BaseResponseModel
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/credit_note.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .fee import FeeResponse
from ..base_model import BaseResponseModel
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/customer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/customer_usage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict, List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
4 changes: 2 additions & 2 deletions lago_python_client/models/event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down Expand Up @@ -30,4 +30,4 @@ class EventResponse(BaseResponseModel):
created_at: str

class BatchEventResponse(BaseResponseModel):
events: List[EventResponse]
events: List[EventResponse]
2 changes: 1 addition & 1 deletion lago_python_client/models/group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/invoice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .credit import CreditsResponse
from .customer import CustomerResponse
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/organization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional, List

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
4 changes: 2 additions & 2 deletions lago_python_client/models/plan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from .charge import Charges, ChargesResponse, ChargesOverrides
from .tax import Taxes, TaxesResponse
Expand Down Expand Up @@ -48,4 +48,4 @@ class PlanOverrides(BaseModel):
amount_currency: Optional[str]
trial_period: Optional[float]
charges: Optional[ChargesOverrides]
tax_codes: Optional[List[str]]
tax_codes: Optional[List[str]]
2 changes: 1 addition & 1 deletion lago_python_client/models/subscription.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel
from .plan import PlanOverrides
from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/tax.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/wallet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/wallet_transaction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/webhook_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_model import BaseResponseModel

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/services/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from typing_extensions import Final # type: ignore

from httpx import Response as Response # not a typo! implicit reexport
from pydantic import BaseModel
from lago_python_client.base_model import BaseModel
import typeguard

from ..exceptions import LagoApiError
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/wallets/clients.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Any, ClassVar, Type, Union

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_client import BaseClient
from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/webhook_endpoints/clients.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Any, ClassVar, Type, Union

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel

from ..base_client import BaseClient
from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/webhooks/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
except ImportError:
from typing_extensions import TypedDict

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel
import typeguard

from ..base_client import BaseClient
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install_requires =
classes~=0.4.1 # bugfix auto updates allowed
httpx~=0.24.0 # bugfix auto updates allowed
orjson~=3.8 # minor auto updates allowed
pydantic~=1.10 # minor auto updates allowed
pydantic>=1.10,<3 # minor auto updates allowed
typeguard~=3.0.2 # bugfix auto updates allowed

[options.extras_require]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_response_services.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test response services."""
from copy import deepcopy

from pydantic import BaseModel
from lago_python_client.base_model import BaseModel
import pytest
from httpx import Request, Response

Expand Down
Loading