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

[IMP] Upgrade Pydantic from V1 to V2 #25

Merged
merged 8 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions gopay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def payments(config: dict, services: dict | None = None) -> Payments:
del config[key]

# Use Pydantic to validate the config object
config_model = GopayConfig.parse_obj(config)
config = config_model.dict()
config_model = GopayConfig.model_validate(config)
config = config_model.model_dump()

# Create and return the Payments and GoPay objects
gopay = GoPay(config, services or {})
Expand Down
6 changes: 2 additions & 4 deletions gopay/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from __future__ import annotations

from pydantic import BaseModel, Extra
from pydantic import BaseModel, ConfigDict

from gopay import enums


class GopayModel(BaseModel):
class Config:
use_enum_values = True
extra = Extra.forbid
model_config = ConfigDict(use_enum_values=True, extra="forbid")


class GopayConfig(GopayModel):
Expand Down
Loading