Skip to content

Commit 99b97a7

Browse files
committed
1.0.0 release; added type hints for base model
1 parent 80a8394 commit 99b97a7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: ["3.9", "3.10", "3.11"]
13+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v3
@@ -50,7 +50,7 @@ jobs:
5050
strategy:
5151
fail-fast: false
5252
matrix:
53-
python-version: ["3.9", "3.10", "3.11"]
53+
python-version: ["3.9", "3.10", "3.11", "3.12"]
5454
steps:
5555
- name: Checkout
5656
uses: actions/checkout@v3

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Dev
22
.vscode
33
.venv
4+
.devcontainer
45

56
# Python
6-
*.py[co]
7+
*.py[cod]
78

89
# Dev artifacts
910
.coverage

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "drf-pydantic"
3-
version = "0.5.0"
3+
version = "1.0.0"
44
description = "Use pydantic with the Django REST framework"
55
license = "MIT"
66
authors = ["George Bocharov <[email protected]>"]

src/drf_pydantic/base_model.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import pydantic
44

55
from rest_framework import serializers
6+
from typing_extensions import dataclass_transform
67

78
from drf_pydantic.parse import create_serializer_from_model
89

910

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

0 commit comments

Comments
 (0)