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 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
6 changes: 3 additions & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
Expand Down
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
7 changes: 3 additions & 4 deletions gopay/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from __future__ import annotations

from pydantic import BaseModel, Extra
from pydantic import BaseModel, ConfigDict
from typing import Optional

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