Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/starwars/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def setup():
from .schema import Human, Droid
from .schema import Droid, Human

global human_data, droid_data
luke = Human(
Expand Down
2 changes: 1 addition & 1 deletion examples/starwars_relay/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def setup():
global data

from .schema import Ship, Faction
from .schema import Faction, Ship

xwing = Ship(id="1", name="X-Wing")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from snapshottest import Snapshot


snapshots = Snapshot()

snapshots["test_correctly_fetches_id_name_rebels 1"] = {
Expand Down
46 changes: 7 additions & 39 deletions graphene/__init__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
from .pyutils.version import get_version
from .relay import (
ClientIDMutation,
Connection,
ConnectionField,
GlobalID,
Node,
PageInfo,
is_node,
)
from .types import (
ID,
UUID,
Argument,
Base64,
Boolean,
Context,
Date,
DateTime,
Decimal,
Dynamic,
Enum,
Field,
Float,
InputField,
InputObjectType,
Int,
Interface,
JSONString,
List,
Mutation,
NonNull,
ObjectType,
ResolveInfo,
Scalar,
Schema,
String,
Time,
Union,
)
from .relay import (ClientIDMutation, Connection, ConnectionField, GlobalID,
Node, PageInfo, is_node)
from .types import (ID, UUID, Argument, Base64, Boolean, Context, Date,
DateTime, Decimal, Dynamic, Enum, Field, Float, InputField,
InputObjectType, Int, Interface, JSONString, List,
Mutation, NonNull, ObjectType, ResolveInfo, Scalar, Schema,
String, Time, Union)
from .utils.module_loading import lazy_import
from .utils.resolve_only_args import resolve_only_args

Expand Down
6 changes: 3 additions & 3 deletions graphene/pyutils/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# https://docs.python.org/3/library/dataclasses.html
# Original PEP proposal: PEP 557
# https://www.python.org/dev/peps/pep-0557/
import re
import sys
import copy
import types
import inspect
import keyword
import re
import sys
import types

__all__ = [
"dataclass",
Expand Down
4 changes: 2 additions & 2 deletions graphene/relay/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .node import Node, is_node, GlobalID
from .mutation import ClientIDMutation
from .connection import Connection, ConnectionField, PageInfo
from .mutation import ClientIDMutation
from .node import GlobalID, Node, is_node

__all__ = [
"Node",
Expand Down
3 changes: 2 additions & 1 deletion graphene/relay/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from graphql_relay import connection_from_array

from ..types import Boolean, Enum, Int, Interface, List, NonNull, Scalar, String, Union
from ..types import (Boolean, Enum, Int, Interface, List, NonNull, Scalar,
String, Union)
from ..types.field import Field
from ..types.objecttype import ObjectType, ObjectTypeOptions
from ..utils.thenables import maybe_thenable
Expand Down
3 changes: 2 additions & 1 deletion graphene/relay/tests/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pytest import raises

from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
from ...types import (Argument, Field, Int, List, NonNull, ObjectType, Schema,
String)
from ..connection import Connection, ConnectionField, PageInfo
from ..node import Node

Expand Down
5 changes: 2 additions & 3 deletions graphene/relay/tests/test_connection_async.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from pytest import mark

from graphql_relay.utils import base64
from pytest import mark

from graphene.types import ObjectType, Schema, String
from graphene.relay.connection import Connection, ConnectionField, PageInfo
from graphene.relay.node import Node
from graphene.types import ObjectType, Schema, String

letter_chars = ["A", "B", "C", "D", "E"]

Expand Down
3 changes: 1 addition & 2 deletions graphene/relay/tests/test_connection_query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pytest import mark

from graphql_relay.utils import base64
from pytest import mark

from ...types import ObjectType, Schema, String
from ..connection import Connection, ConnectionField, PageInfo
Expand Down
12 changes: 2 additions & 10 deletions graphene/relay/tests/test_mutation.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
from pytest import mark, raises

from ...types import (
ID,
Argument,
Field,
InputField,
InputObjectType,
NonNull,
ObjectType,
Schema,
)
from ...types import (ID, Argument, Field, InputField, InputObjectType,
NonNull, ObjectType, Schema)
from ...types.scalars import String
from ..mutation import ClientIDMutation

Expand Down
2 changes: 1 addition & 1 deletion graphene/relay/tests/test_mutation_async.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pytest import mark

from graphene.relay.mutation import ClientIDMutation
from graphene.types import ID, Field, ObjectType, Schema
from graphene.types.scalars import String
from graphene.relay.mutation import ClientIDMutation


class SharedFields(object):
Expand Down
1 change: 1 addition & 0 deletions graphene/relay/tests/test_node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re

from graphql_relay import to_global_id

from graphene.tests.utils import dedent
Expand Down
4 changes: 2 additions & 2 deletions graphene/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from promise import Promise, is_thenable
from graphql.error import format_error as format_graphql_error
from graphql.error import GraphQLError
from graphql.error import format_error as format_graphql_error
from promise import Promise, is_thenable

from graphene.types.schema import Schema

Expand Down
2 changes: 1 addition & 1 deletion graphene/types/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def __eq__(self, other):


def to_arguments(args, extra_args=None):
from .unmountedtype import UnmountedType
from .field import Field
from .inputfield import InputField
from .unmountedtype import UnmountedType

if extra_args:
extra_args = sorted(extra_args.items(), key=lambda f: f[1])
Expand Down
2 changes: 1 addition & 1 deletion graphene/types/base64.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from binascii import Error as _Error
from base64 import b64decode, b64encode
from binascii import Error as _Error

from graphql.error import GraphQLError
from graphql.language import StringValueNode, print_ast
Expand Down
12 changes: 3 additions & 9 deletions graphene/types/definitions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from enum import Enum as PyEnum

from graphql import (
GraphQLEnumType,
GraphQLInputObjectType,
GraphQLInterfaceType,
GraphQLObjectType,
GraphQLScalarType,
GraphQLUnionType,
Undefined,
)
from graphql import (GraphQLEnumType, GraphQLInputObjectType,
GraphQLInterfaceType, GraphQLObjectType,
GraphQLScalarType, GraphQLUnionType, Undefined)


class GrapheneGraphQLType:
Expand Down
2 changes: 1 addition & 1 deletion graphene/types/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from collections.abc import Mapping
from functools import partial

from ..utils.deprecated import warn_deprecation
from .argument import Argument, to_arguments
from .mountedtype import MountedType
from .resolver import default_resolver
from .structures import NonNull
from .unmountedtype import UnmountedType
from .utils import get_type
from ..utils.deprecated import warn_deprecation

base_type = type

Expand Down
11 changes: 3 additions & 8 deletions graphene/types/generic.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from __future__ import unicode_literals

from graphql.language.ast import (
BooleanValueNode,
FloatValueNode,
IntValueNode,
ListValueNode,
ObjectValueNode,
StringValueNode,
)
from graphql.language.ast import (BooleanValueNode, FloatValueNode,
IntValueNode, ListValueNode, ObjectValueNode,
StringValueNode)

from graphene.types.scalars import MAX_INT, MIN_INT

Expand Down
2 changes: 1 addition & 1 deletion graphene/types/inputobjecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# For static type checking with Mypy
MYPY = False
if MYPY:
from typing import Dict, Callable # NOQA
from typing import Callable, Dict # NOQA


class InputObjectTypeOptions(BaseOptions):
Expand Down
5 changes: 3 additions & 2 deletions graphene/types/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
from ..utils.get_unbound_function import get_unbound_function
from ..utils.props import props
from .field import Field
from .interface import Interface
from .objecttype import ObjectType, ObjectTypeOptions
from .utils import yank_fields_from_attrs
from .interface import Interface

# For static type checking with Mypy
MYPY = False
if MYPY:
from typing import Callable, Dict, Iterable, Type # NOQA

from .argument import Argument # NOQA
from typing import Dict, Type, Callable, Iterable # NOQA


class MutationOptions(ObjectTypeOptions):
Expand Down
4 changes: 2 additions & 2 deletions graphene/types/objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from .utils import yank_fields_from_attrs

try:
from dataclasses import make_dataclass, field
from dataclasses import field, make_dataclass
except ImportError:
from ..pyutils.dataclasses import make_dataclass, field # type: ignore
from ..pyutils.dataclasses import field, make_dataclass # type: ignore

# For static type checking with Mypy
MYPY = False
Expand Down
8 changes: 2 additions & 6 deletions graphene/types/scalars.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from typing import Any

from graphql.language.ast import (
BooleanValueNode,
FloatValueNode,
IntValueNode,
StringValueNode,
)
from graphql.language.ast import (BooleanValueNode, FloatValueNode,
IntValueNode, StringValueNode)

from .base import BaseOptions, BaseType
from .unmountedtype import UnmountedType
Expand Down
50 changes: 13 additions & 37 deletions graphene/types/schema.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
import inspect
from functools import partial

from graphql import (
default_type_resolver,
get_introspection_query,
graphql,
graphql_sync,
introspection_types,
parse,
print_schema,
subscribe,
validate,
ExecutionResult,
GraphQLArgument,
GraphQLBoolean,
GraphQLError,
GraphQLEnumValue,
GraphQLField,
GraphQLFloat,
GraphQLID,
GraphQLInputField,
GraphQLInt,
GraphQLList,
GraphQLNonNull,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
Undefined,
)
from graphql import (ExecutionResult, GraphQLArgument, GraphQLBoolean,
GraphQLEnumValue, GraphQLError, GraphQLField,
GraphQLFloat, GraphQLID, GraphQLInputField, GraphQLInt,
GraphQLList, GraphQLNonNull, GraphQLObjectType,
GraphQLSchema, GraphQLString, Undefined,
default_type_resolver, get_introspection_query, graphql,
graphql_sync, introspection_types, parse, print_schema,
subscribe, validate)

from ..utils.str_converters import to_camel_case
from ..utils.get_unbound_function import get_unbound_function
from .definitions import (
GrapheneEnumType,
GrapheneGraphQLType,
GrapheneInputObjectType,
GrapheneInterfaceType,
GrapheneObjectType,
GrapheneScalarType,
GrapheneUnionType,
)
from ..utils.str_converters import to_camel_case
from .definitions import (GrapheneEnumType, GrapheneGraphQLType,
GrapheneInputObjectType, GrapheneInterfaceType,
GrapheneObjectType, GrapheneScalarType,
GrapheneUnionType)
from .dynamic import Dynamic
from .enum import Enum
from .field import Field
Expand Down
2 changes: 1 addition & 1 deletion graphene/types/tests/test_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from graphql import GraphQLError

from ..base64 import Base64
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..base64 import Base64


class Query(ObjectType):
Expand Down
1 change: 0 additions & 1 deletion graphene/types/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytz
from graphql import GraphQLError

from pytest import fixture

from ..datetime import Date, DateTime, Time
Expand Down
2 changes: 1 addition & 1 deletion graphene/types/tests/test_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from ..argument import Argument
from ..dynamic import Dynamic
from ..interface import Interface
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface


class MyType(Interface):
Expand Down
Loading