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 Dec 2, 2023
1 parent edd56bb commit 1cb57b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
20 changes: 8 additions & 12 deletions strawberry/experimental/pydantic/first_class.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import dataclasses
from typing import Callable, Dict, List, Optional, Sequence, Type

from pydantic import BaseModel

from strawberry.annotation import StrawberryAnnotation
from strawberry.experimental.pydantic._compat import CompatModelField, get_model_fields
from strawberry.experimental.pydantic.conversion_types import PydanticModel
from strawberry.experimental.pydantic.fields import replace_types_recursively
from strawberry.experimental.pydantic.utils import get_default_factory_for_field
from strawberry.field import StrawberryField


from pydantic import BaseModel


import dataclasses
from typing import Callable, Dict, List, Optional, Sequence, Type

from strawberry.object_type import _get_interfaces
from strawberry.types.types import StrawberryObjectDefinition
from strawberry.utils.deprecations import DEPRECATION_MESSAGES, DeprecatedDescriptor
from strawberry.utils.str_converters import to_camel_case

from strawberry.experimental.pydantic.conversion_types import PydanticModel


def _get_strawberry_fields_from_basemodel(
model: Type[BaseModel], is_input: bool, use_pydantic_alias: bool
Expand Down Expand Up @@ -153,7 +149,7 @@ def first_class(
) -> Callable[[Type[PydanticModel]], Type[PydanticModel]]:
"""A decorator to make a pydantic class work on strawberry without creating
a separate strawberry type.
Example:
@strawberry.experimental.pydantic.first_class()
class User(BaseModel):
Expand All @@ -165,7 +161,7 @@ class Query:
@strawberry.field
def user(self) -> User:
return User(id=1, name="Patrick")
"""

def wrap(model: Type[PydanticModel]) -> Type[PydanticModel]:
Expand Down
1 change: 0 additions & 1 deletion strawberry/experimental/pydantic/object_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from strawberry.types.type_resolver import _get_fields
from strawberry.utils.dataclasses import add_custom_init_fn


if TYPE_CHECKING:
from graphql import GraphQLResolveInfo

Expand Down
20 changes: 3 additions & 17 deletions tests/experimental/pydantic_first_class/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
import dataclasses
import sys
import textwrap
from enum import Enum
from typing import Annotated, Any, List, Optional, Union
from graphql import is_input_type

import pydantic
import pytest

import strawberry
from tests.experimental.pydantic.utils import needs_pydantic_v1

from strawberry.enum import EnumDefinition
from strawberry.experimental.pydantic.first_class import (
first_class,
)

from strawberry.types.types import StrawberryObjectDefinition

from strawberry.schema_directive import Location
from strawberry.type import StrawberryList, StrawberryOptional

from strawberry.experimental.pydantic.exceptions import MissingFieldsListError

from strawberry.types.types import StrawberryObjectDefinition
from strawberry.union import StrawberryUnion

from strawberry.enum import EnumDefinition

from strawberry.schema_directive import Location

from strawberry.experimental.pydantic.first_class import register_first_class


def test_basic_type_field_list():
@first_class()
Expand Down

0 comments on commit 1cb57b7

Please sign in to comment.