Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 25, 2023
1 parent 017e168 commit 2103eab
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 28 deletions.
10 changes: 3 additions & 7 deletions strawberry/experimental/pydantic/v2_compat.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import pydantic

if pydantic.VERSION[0] == "2":
from pydantic._internal._utils import smart_deepcopy
from pydantic._internal._utils import lenient_issubclass
from typing_extensions import get_args, get_origin
from pydantic._internal._typing_extra import is_new_type

from pydantic._internal._utils import lenient_issubclass, smart_deepcopy

def new_type_supertype(type_):
return type_.__supertype__

else:
from pydantic.utils import smart_deepcopy
from pydantic.utils import lenient_issubclass
from pydantic.typing import get_args, get_origin, is_new_type, new_type_supertype
from pydantic.utils import lenient_issubclass, smart_deepcopy

__all__ = ["smart_deepcopy", "lenient_issubclass"]
1 change: 0 additions & 1 deletion strawberry/experimental/pydantic2/error_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from strawberry.types.type_resolver import _get_fields
from strawberry.utils.typing import get_list_annotation, is_list


from .exceptions import MissingFieldsListError

if TYPE_CHECKING:
Expand Down
19 changes: 7 additions & 12 deletions strawberry/experimental/pydantic2/fields.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import builtins
from decimal import Decimal
from typing import Any, List, Optional, Type
from uuid import UUID
from typing import Any, Type

import pydantic
from pydantic import BaseModel

from strawberry.experimental.pydantic2.exceptions import (
UnregisteredTypeException,
UnsupportedTypeError,
)
from strawberry.experimental.pydantic2.v2_compat import (
lenient_issubclass,
get_args,
get_origin,
is_new_type,
lenient_issubclass,
new_type_supertype,
)
from strawberry.experimental.pydantic2.exceptions import (
UnregisteredTypeException,
UnsupportedTypeError,
)
from strawberry.types.types import TypeDefinition

try:
Expand All @@ -42,13 +41,9 @@

def get_basic_type(type_: Any) -> Type[Any]:
# if lenient_issubclass(type_, pydantic.ConstrainedInt):
# return int
# if lenient_issubclass(type_, pydantic.ConstrainedFloat):
# return float
# if lenient_issubclass(type_, pydantic.ConstrainedStr):
# return str
# if lenient_issubclass(type_, pydantic.ConstrainedList):
# return List[get_basic_type(type_.item_type)] # type: ignore

if type_ in FIELDS_MAP:
type_ = FIELDS_MAP.get(type_)
Expand Down
2 changes: 1 addition & 1 deletion strawberry/experimental/pydantic2/object_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

if TYPE_CHECKING:
from graphql import GraphQLResolveInfo
from pydantic.fields import FieldInfo, FieldInfo
from pydantic.fields import FieldInfo


def is_required(field: FieldInfo) -> bool:
Expand Down
10 changes: 3 additions & 7 deletions strawberry/experimental/pydantic2/v2_compat.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import pydantic

if pydantic.VERSION[0] == "2":
from pydantic._internal._utils import smart_deepcopy
from pydantic._internal._utils import lenient_issubclass
from typing_extensions import get_args, get_origin
from pydantic._internal._typing_extra import is_new_type

from pydantic._internal._utils import lenient_issubclass, smart_deepcopy

def new_type_supertype(type_):
return type_.__supertype__

else:
from pydantic.utils import smart_deepcopy
from pydantic.utils import lenient_issubclass
from pydantic.typing import get_args, get_origin, is_new_type, new_type_supertype
from pydantic.utils import lenient_issubclass, smart_deepcopy

__all__ = ["smart_deepcopy", "lenient_issubclass"]

0 comments on commit 2103eab

Please sign in to comment.