Skip to content

Commit

Permalink
1.0.0 release; added type hints for base model
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebv committed Jan 18, 2024
1 parent 80a8394 commit 99b97a7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Dev
.vscode
.venv
.devcontainer

# Python
*.py[co]
*.py[cod]

# Dev artifacts
.coverage
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "drf-pydantic"
version = "0.5.0"
version = "1.0.0"
description = "Use pydantic with the Django REST framework"
license = "MIT"
authors = ["George Bocharov <bocharovgeorgii@gmail.com>"]
Expand Down
4 changes: 3 additions & 1 deletion src/drf_pydantic/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import pydantic

from rest_framework import serializers
from typing_extensions import dataclass_transform

from drf_pydantic.parse import create_serializer_from_model


@dataclass_transform(kw_only_default=True, field_specifiers=(pydantic.Field,))
class ModelMetaclass(pydantic.main.ModelMetaclass, type):
def __new__(mcs, name, bases, namespace, **kwargs):
cls = super().__new__(mcs, name, bases, namespace, **kwargs)
Expand All @@ -17,4 +19,4 @@ def __new__(mcs, name, bases, namespace, **kwargs):
class BaseModel(pydantic.BaseModel, metaclass=ModelMetaclass):
if typing.TYPE_CHECKING:
# populated by the metaclass, defined here to help IDEs only
drf_serializer: type[serializers.Serializer]
drf_serializer: typing.ClassVar[type[serializers.Serializer]]

0 comments on commit 99b97a7

Please sign in to comment.