Skip to content

Commit

Permalink
Merge pull request #36 from geeshta/feature/pydantic-2.8.2
Browse files Browse the repository at this point in the history
Merge branch Feature/pydantic 2.8.2
  • Loading branch information
geeshta authored Sep 18, 2024
2 parents 0bf3ef9 + 4b1facd commit 9185430
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 352 deletions.
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

0 comments on commit 9185430

Please sign in to comment.