mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-10-26 05:31:05 +03:00 
			
		
		
		
	Fixed PEP8 errors
This commit is contained in:
		
							parent
							
								
									9f1c5fa682
								
							
						
					
					
						commit
						6fa32a7287
					
				|  | @ -22,12 +22,14 @@ class Character(graphene.Interface): | |||
| 
 | ||||
| 
 | ||||
| class Human(graphene.ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = (Character, ) | ||||
|     home_planet = graphene.String() | ||||
| 
 | ||||
| 
 | ||||
| class Droid(graphene.ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = (Character, ) | ||||
|     primary_function = graphene.String() | ||||
|  |  | |||
|  | @ -6,16 +6,15 @@ import six | |||
| 
 | ||||
| from graphql_relay import connection_from_list | ||||
| 
 | ||||
| from ..types import Boolean, String, List, Int | ||||
| from ..types import Boolean, Int, List, String | ||||
| from ..types.field import Field | ||||
| from ..types.objecttype import ObjectType, ObjectTypeMeta | ||||
| from ..types.options import Options | ||||
| from ..types.utils import get_fields_in_type, yank_fields_from_attrs | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from ..utils.props import props | ||||
| from .node import Node, is_node | ||||
| 
 | ||||
| from ..types.utils import get_fields_in_type, yank_fields_from_attrs | ||||
| 
 | ||||
| 
 | ||||
| class PageInfo(ObjectType): | ||||
|     has_next_page = Boolean( | ||||
|  | @ -66,7 +65,6 @@ class ConnectionMeta(ObjectTypeMeta): | |||
|         if not options.name: | ||||
|             options.name = '{}Connection'.format(base_name) | ||||
| 
 | ||||
| 
 | ||||
|         edge_class = attrs.pop('Edge', None) | ||||
|         edge_fields = OrderedDict([ | ||||
|             ('node', Field(options.node, description='The item at the end of the edge')), | ||||
|  | @ -75,28 +73,29 @@ class ConnectionMeta(ObjectTypeMeta): | |||
|         edge_attrs = props(edge_class) if edge_class else OrderedDict() | ||||
|         extended_edge_fields = get_fields_in_type(ObjectType, edge_attrs) | ||||
|         edge_fields.update(extended_edge_fields) | ||||
|         EdgeMeta = type('Meta', (object, ), { | ||||
|         edge_meta = type('Meta', (object, ), { | ||||
|             'fields': edge_fields, | ||||
|             'name': '{}Edge'.format(base_name) | ||||
|         }) | ||||
|         yank_fields_from_attrs(edge_attrs, extended_edge_fields) | ||||
|         Edge = type('Edge', (ObjectType,), dict(edge_attrs, Meta=EdgeMeta)) | ||||
|         edge = type('Edge', (ObjectType,), dict(edge_attrs, Meta=edge_meta)) | ||||
| 
 | ||||
|         options.local_fields = OrderedDict([ | ||||
|             ('page_info', Field(PageInfo, name='pageInfo', required=True)), | ||||
|             ('edges', Field(List(Edge))) | ||||
|             ('edges', Field(List(edge))) | ||||
|         ]) | ||||
|         typed_fields = get_fields_in_type(ObjectType, attrs) | ||||
|         options.local_fields.update(typed_fields) | ||||
|         options.fields = options.local_fields | ||||
|         yank_fields_from_attrs(attrs, typed_fields) | ||||
| 
 | ||||
|         return type.__new__(cls, name, bases, dict(attrs, _meta=options, Edge=Edge)) | ||||
|         return type.__new__(cls, name, bases, dict(attrs, _meta=options, Edge=edge)) | ||||
| 
 | ||||
| 
 | ||||
| class Connection(six.with_metaclass(ConnectionMeta, ObjectType)): | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| class IterableConnectionField(Field): | ||||
| 
 | ||||
|     def __init__(self, type, *args, **kwargs): | ||||
|  |  | |||
|  | @ -1,14 +1,13 @@ | |||
| import re | ||||
| from functools import partial | ||||
| 
 | ||||
| import six | ||||
| import re | ||||
| 
 | ||||
| from promise import Promise | ||||
| 
 | ||||
| from ..types import Argument, Field, InputObjectType, String | ||||
| from ..types.objecttype import ObjectType, ObjectTypeMeta | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from ..utils.props import props | ||||
| from ..types import Field, String, InputObjectType, Argument | ||||
| from ..types.objecttype import ObjectType, ObjectTypeMeta | ||||
| 
 | ||||
| 
 | ||||
| class ClientIDMutationMeta(ObjectTypeMeta): | ||||
|  | @ -36,6 +35,7 @@ class ClientIDMutationMeta(ObjectTypeMeta): | |||
| 
 | ||||
| 
 | ||||
| class ClientIDMutation(six.with_metaclass(ClientIDMutationMeta, ObjectType)): | ||||
| 
 | ||||
|     @classmethod | ||||
|     def mutate(cls, root, args, context, info): | ||||
|         input = args.get('input') | ||||
|  |  | |||
|  | @ -1,9 +1,10 @@ | |||
| import six | ||||
| from collections import OrderedDict | ||||
| from functools import partial | ||||
| 
 | ||||
| import six | ||||
| 
 | ||||
| from graphql_relay import from_global_id, to_global_id | ||||
| from ..types import ObjectType, Interface, ID, Field | ||||
| 
 | ||||
| from ..types import ID, Field, Interface, ObjectType | ||||
| from ..types.interface import InterfaceMeta | ||||
| 
 | ||||
| 
 | ||||
|  | @ -27,6 +28,7 @@ def get_default_connection(cls): | |||
| 
 | ||||
| 
 | ||||
| class GlobalID(Field): | ||||
| 
 | ||||
|     def __init__(self, node, *args, **kwargs): | ||||
|         super(GlobalID, self).__init__(ID, *args, **kwargs) | ||||
|         self.node = node | ||||
|  | @ -52,7 +54,7 @@ class Node(six.with_metaclass(NodeMeta, Interface)): | |||
|     '''An object with an ID''' | ||||
| 
 | ||||
|     @classmethod | ||||
|     def Field(cls): | ||||
|     def Field(cls):  # noqa: N802 | ||||
|         def resolve_node(root, args, context, info): | ||||
|             return cls.get_node_from_global_id(args.get('id'), context, info) | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,10 +1,11 @@ | |||
| 
 | ||||
| from ...types import ObjectType, Schema, List, Field, String, NonNull | ||||
| from ...types import Field, List, NonNull, ObjectType, Schema, String | ||||
| from ..connection import Connection, PageInfo | ||||
| from ..node import Node | ||||
| 
 | ||||
| 
 | ||||
| class MyObject(ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = [Node] | ||||
|     field = String() | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ...types import ObjectType, Schema, Field, InputField, InputObjectType, Argument | ||||
| from ...types import (Argument, Field, InputField, InputObjectType, ObjectType, | ||||
|                       Schema) | ||||
| from ...types.scalars import String | ||||
| from ..mutation import ClientIDMutation | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ from ..node import Node | |||
| 
 | ||||
| 
 | ||||
| class MyNode(ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = (Node, ) | ||||
|     name = String() | ||||
|  | @ -27,6 +28,7 @@ schema = Schema(query=RootQuery, types=[MyNode]) | |||
| def test_node_no_get_node(): | ||||
|     with pytest.raises(AssertionError) as excinfo: | ||||
|         class MyNode(ObjectType): | ||||
| 
 | ||||
|             class Meta: | ||||
|                 interfaces = (Node, ) | ||||
| 
 | ||||
|  | @ -36,6 +38,7 @@ def test_node_no_get_node(): | |||
| def test_node_no_get_node_with_meta(): | ||||
|     with pytest.raises(AssertionError) as excinfo: | ||||
|         class MyNode(ObjectType): | ||||
| 
 | ||||
|             class Meta: | ||||
|                 interfaces = (Node, ) | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,11 +1,12 @@ | |||
| from graphql import graphql | ||||
| 
 | ||||
| from ...types import ObjectType, Interface, Schema | ||||
| from ...types import Interface, ObjectType, Schema | ||||
| from ...types.scalars import Int, String | ||||
| from ..node import Node | ||||
| 
 | ||||
| 
 | ||||
| class CustomNode(Node): | ||||
| 
 | ||||
|     class Meta: | ||||
|         name = 'Node' | ||||
| 
 | ||||
|  | @ -27,12 +28,14 @@ class BasePhoto(Interface): | |||
| 
 | ||||
| 
 | ||||
| class User(ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = [CustomNode] | ||||
|     name = String() | ||||
| 
 | ||||
| 
 | ||||
| class Photo(ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = [CustomNode, BasePhoto] | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,8 +8,8 @@ from .enum import Enum | |||
| from .field import Field | ||||
| from .inputfield import InputField | ||||
| from .argument import Argument | ||||
| from .dynamic import Dynamic | ||||
| from .inputobjecttype import InputObjectType | ||||
| from .dynamic import Dynamic | ||||
| 
 | ||||
| __all__ = [ | ||||
|     'AbstractType', | ||||
|  | @ -28,4 +28,5 @@ __all__ = [ | |||
|     'Boolean', | ||||
|     'List', | ||||
|     'NonNull', | ||||
|     'Argument'] | ||||
|     'Argument' | ||||
|     'Dynamic'] | ||||
|  |  | |||
|  | @ -2,8 +2,8 @@ import six | |||
| 
 | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from .options import Options | ||||
| 
 | ||||
| from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs | ||||
| from .utils import (get_fields_in_type, merge_fields_in_attrs, | ||||
|                     yank_fields_from_attrs) | ||||
| 
 | ||||
| 
 | ||||
| class AbstractTypeMeta(type): | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| import inspect | ||||
| 
 | ||||
| from ..utils.orderedtype import OrderedType | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -41,14 +41,15 @@ class EnumTypeMeta(type): | |||
|             return cls.from_enum(PyEnum(*args, **kwargs), description=description) | ||||
|         return super(EnumTypeMeta, cls).__call__(*args, **kwargs) | ||||
| 
 | ||||
|     def from_enum(cls, enum, description=None): | ||||
|     def from_enum(cls, enum, description=None):  # noqa: N805 | ||||
|         meta_class = type('Meta', (object,), {'enum': enum, 'description': description}) | ||||
|         return type(meta_class.enum.__name__, (Enum,), {'Meta': meta_class}) | ||||
| 
 | ||||
|     def __str__(cls): | ||||
|     def __str__(cls):  # noqa: N805 | ||||
|         return cls._meta.name | ||||
| 
 | ||||
| 
 | ||||
| class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)): | ||||
| 
 | ||||
|     def get_type(self): | ||||
|         return type(self) | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| import inspect | ||||
| from collections import Mapping, OrderedDict | ||||
| from functools import partial | ||||
| from collections import OrderedDict, Mapping | ||||
| 
 | ||||
| from ..utils.orderedtype import OrderedType | ||||
| from .structures import NonNull | ||||
| from .argument import to_arguments | ||||
| from .structures import NonNull | ||||
| 
 | ||||
| 
 | ||||
| def source_resolver(source, root, args, context, info): | ||||
|  |  | |||
|  | @ -1,11 +1,11 @@ | |||
| import six | ||||
| 
 | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from .options import Options | ||||
| 
 | ||||
| from .abstracttype import AbstractTypeMeta | ||||
| from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs | ||||
| from .options import Options | ||||
| from .unmountedtype import UnmountedType | ||||
| from .utils import (get_fields_in_type, merge_fields_in_attrs, | ||||
|                     yank_fields_from_attrs) | ||||
| 
 | ||||
| 
 | ||||
| class InputObjectTypeMeta(AbstractTypeMeta): | ||||
|  | @ -30,7 +30,7 @@ class InputObjectTypeMeta(AbstractTypeMeta): | |||
| 
 | ||||
|         return type.__new__(cls, name, bases, dict(attrs, _meta=options)) | ||||
| 
 | ||||
|     def __str__(cls): | ||||
|     def __str__(cls):  # noqa: N802 | ||||
|         return cls._meta.name | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| import six | ||||
| 
 | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from .options import Options | ||||
| 
 | ||||
| from .abstracttype import AbstractTypeMeta | ||||
| from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs | ||||
| from .options import Options | ||||
| from .utils import (get_fields_in_type, merge_fields_in_attrs, | ||||
|                     yank_fields_from_attrs) | ||||
| 
 | ||||
| 
 | ||||
| class InterfaceMeta(AbstractTypeMeta): | ||||
|  | @ -29,7 +29,7 @@ class InterfaceMeta(AbstractTypeMeta): | |||
| 
 | ||||
|         return type.__new__(cls, name, bases, dict(attrs, _meta=options)) | ||||
| 
 | ||||
|     def __str__(cls): | ||||
|     def __str__(cls):  # noqa: N802 | ||||
|         return cls._meta.name | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,12 +1,13 @@ | |||
| from collections import OrderedDict | ||||
| 
 | ||||
| import six | ||||
| 
 | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from .options import Options | ||||
| 
 | ||||
| from .abstracttype import AbstractTypeMeta | ||||
| from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs | ||||
| from .interface import Interface | ||||
| from .options import Options | ||||
| from .utils import (get_fields_in_type, merge_fields_in_attrs, | ||||
|                     yank_fields_from_attrs) | ||||
| 
 | ||||
| 
 | ||||
| class ObjectTypeMeta(AbstractTypeMeta): | ||||
|  | @ -45,11 +46,12 @@ class ObjectTypeMeta(AbstractTypeMeta): | |||
| 
 | ||||
|         return cls | ||||
| 
 | ||||
|     def __str__(cls): | ||||
|     def __str__(cls):  # noqa: N802 | ||||
|         return cls._meta.name | ||||
| 
 | ||||
| 
 | ||||
| class ObjectType(six.with_metaclass(ObjectTypeMeta)): | ||||
| 
 | ||||
|     @classmethod | ||||
|     def is_type_of(cls, root, context, info): | ||||
|         if isinstance(root, cls): | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| import inspect | ||||
| 
 | ||||
| from ..utils.props import props | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| import six | ||||
| 
 | ||||
| from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue | ||||
| from graphql.language.ast import (BooleanValue, FloatValue, IntValue, | ||||
|                                   StringValue) | ||||
| 
 | ||||
| from ..utils.is_base_type import is_base_type | ||||
| from .options import Options | ||||
|  | @ -25,7 +26,7 @@ class ScalarTypeMeta(type): | |||
| 
 | ||||
|         return super_new(cls, name, bases, dict(attrs, _meta=options)) | ||||
| 
 | ||||
|     def __str__(cls): | ||||
|     def __str__(cls):  # noqa: N802 | ||||
|         return cls._meta.name | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,13 +1,14 @@ | |||
| import inspect | ||||
| 
 | ||||
| from graphql import GraphQLSchema, MiddlewareManager, graphql, is_type | ||||
| from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective, | ||||
|                                      GraphQLSkipDirective) | ||||
| from graphql.type.introspection import IntrospectionSchema | ||||
| from graphql.utils.introspection_query import introspection_query | ||||
| from graphql.utils.schema_printer import print_schema | ||||
| 
 | ||||
| from .typemap import TypeMap, is_graphene_type | ||||
| 
 | ||||
| 
 | ||||
| from .objecttype import ObjectType | ||||
| from .structures import List, NonNull | ||||
| from .scalars import Scalar, String | ||||
| # from ..utils.get_graphql_type import get_graphql_type | ||||
| 
 | ||||
| 
 | ||||
|  | @ -16,15 +17,10 @@ from .scalars import Scalar, String | |||
| # from collections import defaultdict | ||||
| 
 | ||||
| 
 | ||||
| from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective, | ||||
|                                      GraphQLSkipDirective) | ||||
| from graphql.type.introspection import IntrospectionSchema | ||||
| from .typemap import TypeMap, is_graphene_type | ||||
| 
 | ||||
| 
 | ||||
| class Schema(GraphQLSchema): | ||||
| 
 | ||||
|     def __init__(self, query=None, mutation=None, subscription=None, directives=None, types=None, executor=None, middlewares=None): | ||||
|     def __init__(self, query=None, mutation=None, subscription=None, | ||||
|                  directives=None, types=None, executor=None, middlewares=None): | ||||
|         self._query = query | ||||
|         self._mutation = mutation | ||||
|         self._subscription = subscription | ||||
|  |  | |||
|  | @ -16,10 +16,12 @@ class Structure(UnmountedType): | |||
| 
 | ||||
| 
 | ||||
| class List(Structure): | ||||
| 
 | ||||
|     def __str__(self): | ||||
|         return '[{}]'.format(self.of_type) | ||||
| 
 | ||||
| 
 | ||||
| class NonNull(Structure): | ||||
| 
 | ||||
|     def __str__(self): | ||||
|         return '{}!'.format(self.of_type) | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..field import Field | ||||
| from ..abstracttype import AbstractType | ||||
| from ..field import Field | ||||
| from ..unmountedtype import UnmountedType | ||||
| 
 | ||||
| 
 | ||||
|  | @ -10,6 +9,7 @@ class MyType(object): | |||
| 
 | ||||
| 
 | ||||
| class MyScalar(UnmountedType): | ||||
| 
 | ||||
|     def get_type(self): | ||||
|         return MyType | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,20 +1,17 @@ | |||
| from collections import OrderedDict | ||||
| 
 | ||||
| from py.test import raises | ||||
| 
 | ||||
| from ..abstracttype import AbstractType | ||||
| from ..objecttype import ObjectType | ||||
| from ..interface import Interface | ||||
| from ..union import Union | ||||
| from ..scalars import String, Int, Boolean | ||||
| from ..argument import Argument | ||||
| from ..enum import Enum | ||||
| from ..field import Field | ||||
| from ..inputfield import InputField | ||||
| from ..structures import List, NonNull | ||||
| from ..enum import Enum | ||||
| from ..argument import Argument | ||||
| from ..inputobjecttype import InputObjectType | ||||
| 
 | ||||
| from ..interface import Interface | ||||
| from ..objecttype import ObjectType | ||||
| from ..scalars import Boolean, Int, String | ||||
| from ..schema import Schema | ||||
| from ..structures import List, NonNull | ||||
| from ..union import Union | ||||
| 
 | ||||
| 
 | ||||
| class Image(ObjectType): | ||||
|  | @ -60,6 +57,7 @@ class MyInterface(Interface): | |||
| 
 | ||||
| 
 | ||||
| class MyUnion(Union): | ||||
| 
 | ||||
|     class Meta: | ||||
|         types = (Article, ) | ||||
| 
 | ||||
|  | @ -145,6 +143,7 @@ def test_includes_interfaces_thunk_subtypes_in_the_type_map(): | |||
|         f = Int() | ||||
| 
 | ||||
|     class SomeSubtype(ObjectType): | ||||
| 
 | ||||
|         class Meta: | ||||
|             interfaces = (SomeInterface, ) | ||||
| 
 | ||||
|  | @ -167,6 +166,7 @@ def test_includes_types_in_union(): | |||
|         b = String() | ||||
| 
 | ||||
|     class MyUnion(Union): | ||||
| 
 | ||||
|         class Meta: | ||||
|             types = (SomeType, OtherType) | ||||
| 
 | ||||
|  | @ -189,6 +189,7 @@ def test_maps_enum(): | |||
|         b = String() | ||||
| 
 | ||||
|     class MyUnion(Union): | ||||
| 
 | ||||
|         class Meta: | ||||
|             types = (SomeType, OtherType) | ||||
| 
 | ||||
|  | @ -208,6 +209,7 @@ def test_includes_interfaces_subtypes_in_the_type_map(): | |||
|         f = Int() | ||||
| 
 | ||||
|     class SomeSubtype(ObjectType): | ||||
| 
 | ||||
|         class Meta: | ||||
|             interfaces = (SomeInterface, ) | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,6 +30,7 @@ def test_enum_construction(): | |||
| 
 | ||||
| def test_enum_construction_meta(): | ||||
|     class RGB(Enum): | ||||
| 
 | ||||
|         class Meta: | ||||
|             name = 'RGBEnum' | ||||
|             description = 'Description' | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..argument import Argument | ||||
| from ..field import Field | ||||
| from ..structures import NonNull | ||||
| from ..argument import Argument | ||||
| 
 | ||||
| 
 | ||||
| class MyInstance(object): | ||||
|  |  | |||
|  | @ -1,10 +1,9 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..abstracttype import AbstractType | ||||
| from ..field import Field | ||||
| from ..inputfield import InputField | ||||
| from ..inputobjecttype import InputObjectType | ||||
| from ..unmountedtype import UnmountedType | ||||
| from ..abstracttype import AbstractType | ||||
| 
 | ||||
| 
 | ||||
| class MyType(object): | ||||
|  | @ -12,6 +11,7 @@ class MyType(object): | |||
| 
 | ||||
| 
 | ||||
| class MyScalar(UnmountedType): | ||||
| 
 | ||||
|     def get_type(self): | ||||
|         return MyType | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,9 +1,8 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..abstracttype import AbstractType | ||||
| from ..field import Field | ||||
| from ..interface import Interface | ||||
| from ..unmountedtype import UnmountedType | ||||
| from ..abstracttype import AbstractType | ||||
| 
 | ||||
| 
 | ||||
| class MyType(object): | ||||
|  | @ -11,6 +10,7 @@ class MyType(object): | |||
| 
 | ||||
| 
 | ||||
| class MyScalar(UnmountedType): | ||||
| 
 | ||||
|     def get_type(self): | ||||
|         return MyType | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,9 +1,7 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..field import Field | ||||
| from ..mutation import Mutation | ||||
| from ..objecttype import ObjectType | ||||
| from ..scalars import String | ||||
| 
 | ||||
| 
 | ||||
| def test_generate_mutation_no_args(): | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..abstracttype import AbstractType | ||||
| from ..field import Field | ||||
| from ..interface import Interface | ||||
| from ..objecttype import ObjectType | ||||
| from ..unmountedtype import UnmountedType | ||||
| from ..abstracttype import AbstractType | ||||
| from ..interface import Interface | ||||
| 
 | ||||
| 
 | ||||
| class MyType(Interface): | ||||
|  | @ -21,6 +21,7 @@ class MyInterface(Interface): | |||
| 
 | ||||
| 
 | ||||
| class ContainerWithInterface(ObjectType): | ||||
| 
 | ||||
|     class Meta: | ||||
|         interfaces = (MyInterface, ) | ||||
|     field1 = Field(MyType) | ||||
|  | @ -28,6 +29,7 @@ class ContainerWithInterface(ObjectType): | |||
| 
 | ||||
| 
 | ||||
| class MyScalar(UnmountedType): | ||||
| 
 | ||||
|     def get_type(self): | ||||
|         return MyType | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,13 +1,7 @@ | |||
| from collections import OrderedDict | ||||
| 
 | ||||
| from py.test import raises | ||||
| from graphql import MiddlewareManager | ||||
| 
 | ||||
| from ..objecttype import ObjectType | ||||
| from ..scalars import String, Int, Boolean | ||||
| from ..field import Field | ||||
| from ..structures import List | ||||
| 
 | ||||
| from ..scalars import String | ||||
| from ..schema import Schema | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| from ..scalars import (Boolean, Float, Int, String) | ||||
| from ..scalars import Boolean, Float, Int, String | ||||
| 
 | ||||
| 
 | ||||
| def test_serializes_output_int(): | ||||
|  |  | |||
|  | @ -1,15 +1,13 @@ | |||
| import pytest | ||||
| 
 | ||||
| from ..objecttype import ObjectType | ||||
| from ..union import Union | ||||
| from ..field import Field | ||||
| from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue, | ||||
|                           GraphQLField, GraphQLObjectType, GraphQLString) | ||||
| 
 | ||||
| from ..dynamic import Dynamic | ||||
| from ..enum import Enum | ||||
| from ..typemap import TypeMap | ||||
| from ..field import Field | ||||
| from ..objecttype import ObjectType | ||||
| from ..scalars import String | ||||
| 
 | ||||
| 
 | ||||
| from graphql.type import GraphQLEnumType, GraphQLEnumValue, GraphQLObjectType, GraphQLField, GraphQLArgument, GraphQLString | ||||
| from ..typemap import TypeMap | ||||
| 
 | ||||
| 
 | ||||
| def test_enum(): | ||||
|  |  | |||
|  | @ -25,6 +25,7 @@ def test_generate_union(): | |||
| 
 | ||||
| def test_generate_union_with_meta(): | ||||
|     class MyUnion(Union): | ||||
| 
 | ||||
|         class Meta: | ||||
|             name = 'MyOtherUnion' | ||||
|             description = 'Documentation' | ||||
|  |  | |||
|  | @ -1,22 +1,22 @@ | |||
| import inspect | ||||
| from functools import partial | ||||
| from collections import OrderedDict | ||||
| from functools import partial | ||||
| 
 | ||||
| from graphql import (GraphQLArgument, GraphQLBoolean, GraphQLField, | ||||
|                      GraphQLFloat, GraphQLID, GraphQLInputObjectField, | ||||
|                      GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLString) | ||||
| from graphql.type import GraphQLEnumValue | ||||
| from graphql.type.typemap import GraphQLTypeMap | ||||
| 
 | ||||
| from .objecttype import ObjectType | ||||
| from .interface import Interface | ||||
| from .union import Union | ||||
| from .inputobjecttype import InputObjectType | ||||
| from .structures import List, NonNull | ||||
| from .enum import Enum | ||||
| from .scalars import Scalar, String, Boolean, Int, Float, ID | ||||
| from .dynamic import Dynamic | ||||
| 
 | ||||
| from graphql import GraphQLString, GraphQLField, GraphQLList, GraphQLBoolean, GraphQLInt, GraphQLFloat, GraphQLID, GraphQLNonNull, GraphQLInputObjectField, GraphQLArgument | ||||
| from graphql.type import GraphQLEnumValue | ||||
| 
 | ||||
| from ..utils.str_converters import to_camel_case | ||||
| from .dynamic import Dynamic | ||||
| from .enum import Enum | ||||
| from .inputobjecttype import InputObjectType | ||||
| from .interface import Interface | ||||
| from .objecttype import ObjectType | ||||
| from .scalars import ID, Boolean, Float, Int, Scalar, String | ||||
| from .structures import List, NonNull | ||||
| from .union import Union | ||||
| 
 | ||||
| 
 | ||||
| def is_graphene_type(_type): | ||||
|  | @ -252,11 +252,11 @@ class TypeMap(GraphQLTypeMap): | |||
|         return partial(cls.default_resolver, name) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def get_field_type(self, map, type): | ||||
|     def get_field_type(cls, map, type): | ||||
|         if isinstance(type, List): | ||||
|             return GraphQLList(self.get_field_type(map, type.of_type)) | ||||
|             return GraphQLList(cls.get_field_type(map, type.of_type)) | ||||
|         if isinstance(type, NonNull): | ||||
|             return GraphQLNonNull(self.get_field_type(map, type.of_type)) | ||||
|             return GraphQLNonNull(cls.get_field_type(map, type.of_type)) | ||||
|         if inspect.isfunction(type): | ||||
|             type = type() | ||||
|         return map.get(type._meta.name) | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ class UnionMeta(type): | |||
| 
 | ||||
|         return type.__new__(cls, name, bases, dict(attrs, _meta=options)) | ||||
| 
 | ||||
|     def __str__(cls): | ||||
|     def __str__(cls):  # noqa: N805 | ||||
|         return cls._meta.name | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ class UnmountedType(OrderedType): | |||
|     def get_type(self): | ||||
|         raise NotImplementedError("get_type not implemented in {}".format(self)) | ||||
| 
 | ||||
|     def Field(self): | ||||
|     def Field(self):  # noqa: N802 | ||||
|         ''' | ||||
|         Mount the UnmountedType as Field | ||||
|         ''' | ||||
|  | @ -35,7 +35,7 @@ class UnmountedType(OrderedType): | |||
|             **self.kwargs | ||||
|         ) | ||||
| 
 | ||||
|     def InputField(self): | ||||
|     def InputField(self):  # noqa: N802 | ||||
|         ''' | ||||
|         Mount the UnmountedType as InputField | ||||
|         ''' | ||||
|  | @ -47,7 +47,7 @@ class UnmountedType(OrderedType): | |||
|             **self.kwargs | ||||
|         ) | ||||
| 
 | ||||
|     def Argument(self): | ||||
|     def Argument(self):  # noqa: N802 | ||||
|         ''' | ||||
|         Mount the UnmountedType as Argument | ||||
|         ''' | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| from collections import OrderedDict | ||||
| 
 | ||||
| from .unmountedtype import UnmountedType | ||||
| from .field import Field | ||||
| from .dynamic import Dynamic | ||||
| from .field import Field | ||||
| from .inputfield import InputField | ||||
| from .unmountedtype import UnmountedType | ||||
| 
 | ||||
| 
 | ||||
| def merge_fields_in_attrs(bases, attrs): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user