Skip to content

Commit

Permalink
pre commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
djbios committed Feb 5, 2024
1 parent 0d9cf53 commit 3cfda19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/drf_pydantic/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import pydantic
import pydantic.fields
import pydantic_core
from pydantic import JsonValue

from pydantic import JsonValue
from pydantic._internal._fields import PydanticMetadata
from rest_framework import serializers # type: ignore

Expand Down
13 changes: 11 additions & 2 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

import pydantic
import pytest
from django.db.models import TextChoices
from pydantic import JsonValue, ConfigDict

from drf_pydantic import BaseModel
from drf_pydantic.errors import ModelConversionError
from pydantic import ConfigDict, JsonValue
from rest_framework import serializers


Expand Down Expand Up @@ -90,6 +89,7 @@ class Person(BaseModel):

def test_multiple_regex_error(self):
with pytest.raises(ModelConversionError) as exc_info:

class Person(BaseModel):
phone_number: typing.Annotated[
str,
Expand Down Expand Up @@ -143,6 +143,7 @@ class Stock(BaseModel):
@pytest.mark.filterwarnings("ignore:.*is not supported by DRF.*")
def test_int_with_conflicting_constraints_errors(self):
with pytest.raises(ModelConversionError) as exc_info1:

class Stock1(BaseModel):
price: typing.Annotated[
int,
Expand All @@ -156,6 +157,7 @@ class Stock1(BaseModel):
)

with pytest.raises(ModelConversionError) as exc_info2:

class Stock2(BaseModel):
price: typing.Annotated[
int,
Expand All @@ -169,6 +171,7 @@ class Stock2(BaseModel):
)

with pytest.raises(ModelConversionError) as exc_info3:

class Stock3(BaseModel):
price: typing.Annotated[
int,
Expand All @@ -182,6 +185,7 @@ class Stock3(BaseModel):
)

with pytest.raises(ModelConversionError) as exc_info4:

class Stock4(BaseModel):
price: typing.Annotated[
int,
Expand Down Expand Up @@ -261,6 +265,7 @@ class Person(BaseModel):

def test_decimal_with_conflicting_constraints_error(self):
with pytest.raises(ModelConversionError) as exc_info:

class Person(BaseModel):
salary: typing.Annotated[
decimal.Decimal,
Expand Down Expand Up @@ -356,6 +361,7 @@ class Employee(BaseModel):

def test_unsupported_type_error(self):
with pytest.raises(ModelConversionError) as exc_info:

class CustomType:
...

Expand Down Expand Up @@ -424,6 +430,7 @@ class Person(BaseModel):

def test_tuple_error(self):
with pytest.raises(ModelConversionError) as exc_info:

class Person(BaseModel):
friends: tuple[int, str]

Expand All @@ -443,6 +450,7 @@ class Person(BaseModel):

def test_dict_error(self):
with pytest.raises(ModelConversionError) as exc_info:

class Person(BaseModel):
value: dict[int, str]

Expand Down Expand Up @@ -507,6 +515,7 @@ class Person(BaseModel):

def test_union_field_error(self):
with pytest.raises(ModelConversionError) as exc_info:

class Person(BaseModel):
name: typing.Union[str, int]

Expand Down

0 comments on commit 3cfda19

Please sign in to comment.