Fixed lint errors

This commit is contained in:
Syrus Akbary 2015-12-02 23:46:49 -08:00
parent b417a65f19
commit 9b839f19e5
23 changed files with 56 additions and 37 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
autoflake ./ -r --remove-unused-variables --remove-all-unused-imports --in-place
autopep8 ./ -r --in-place --experimental --aggressive --max-line-length 120
isort -rc .
autoflake ./examples/ ./graphene/ -r --remove-unused-variables --remove-all-unused-imports --in-place
autopep8 ./examples/ ./graphene/ -r --in-place --experimental --aggressive --max-line-length 120
isort -rc ./examples/ ./graphene/

View File

@ -1,6 +1,5 @@
from graphql.core.type import GraphQLInterfaceType, GraphQLObjectType
from graphql.core.type import GraphQLObjectType
from mock import patch
from pytest import raises
from graphene import Schema
from graphene.contrib.django.types import DjangoNode, DjangoObjectType

View File

@ -1,10 +1,10 @@
import six
import inspect
import six
from django.db import models
from ...core.classtypes.objecttype import ObjectTypeMeta, ObjectType
from ...relay.types import Node, NodeMeta, Connection
from ...core.classtypes.objecttype import ObjectType, ObjectTypeMeta
from ...relay.types import Connection, Node, NodeMeta
from .converter import convert_django_field
from .options import DjangoOptions
from .utils import get_reverse_fields, maybe_queryset
@ -47,6 +47,7 @@ class DjangoObjectTypeMeta(ObjectTypeMeta):
class InstanceObjectType(ObjectType):
class Meta:
abstract = True
@ -75,6 +76,7 @@ class InstanceObjectType(ObjectType):
class DjangoObjectType(six.with_metaclass(
DjangoObjectTypeMeta, InstanceObjectType)):
class Meta:
abstract = True
@ -92,12 +94,14 @@ class DjangoNodeMeta(DjangoObjectTypeMeta, NodeMeta):
class NodeInstance(Node, InstanceObjectType):
class Meta:
abstract = True
class DjangoNode(six.with_metaclass(
DjangoNodeMeta, NodeInstance)):
class Meta:
abstract = True

View File

@ -1,7 +1,8 @@
from collections import OrderedDict
import inspect
import six
import copy
import inspect
from collections import OrderedDict
import six
from ..exceptions import SkipField
from .options import Options
@ -54,6 +55,7 @@ class ClassTypeMeta(type):
class ClassType(six.with_metaclass(ClassTypeMeta)):
class Meta:
abstract = True
@ -63,6 +65,7 @@ class ClassType(six.with_metaclass(ClassTypeMeta)):
class FieldsOptions(Options):
def __init__(self, *args, **kwargs):
super(FieldsOptions, self).__init__(*args, **kwargs)
self.local_fields = []
@ -107,7 +110,6 @@ class FieldsClassTypeMeta(ClassTypeMeta):
new_field = copy.copy(field)
cls.add_to_class(field.attname, new_field)
def construct(cls, bases, attrs):
cls = super(FieldsClassTypeMeta, cls).construct(bases, attrs)
cls.extend_fields(bases)
@ -115,6 +117,7 @@ class FieldsClassTypeMeta(ClassTypeMeta):
class FieldsClassType(six.with_metaclass(FieldsClassTypeMeta, ClassType)):
class Meta:
abstract = True

View File

@ -6,6 +6,7 @@ from .base import FieldsClassType
class InputObjectType(FieldsClassType):
class Meta:
abstract = True

View File

@ -1,6 +1,6 @@
import six
from functools import partial
import six
from graphql.core.type import GraphQLInterfaceType
from .base import FieldsClassTypeMeta
@ -8,6 +8,7 @@ from .objecttype import ObjectType, ObjectTypeMeta
class InterfaceMeta(ObjectTypeMeta):
def construct(cls, bases, attrs):
if cls._meta.abstract or Interface in bases:
# Return Interface type
@ -26,6 +27,7 @@ class InterfaceMeta(ObjectTypeMeta):
class Interface(six.with_metaclass(InterfaceMeta, ObjectType)):
class Meta:
abstract = True

View File

@ -5,6 +5,7 @@ from .objecttype import ObjectType, ObjectTypeMeta
class MutationMeta(ObjectTypeMeta):
def construct(cls, bases, attrs):
input_class = attrs.pop('Input', None)
if input_class:
@ -22,6 +23,7 @@ class MutationMeta(ObjectTypeMeta):
class Mutation(six.with_metaclass(MutationMeta, ObjectType)):
class Meta:
abstract = True

View File

@ -1,10 +1,11 @@
import six
from functools import partial
import six
from graphql.core.type import GraphQLObjectType
from graphene import signals
from .base import FieldsOptions, FieldsClassType, FieldsClassTypeMeta
from .base import FieldsClassType, FieldsClassTypeMeta, FieldsOptions
from .uniontype import UnionType
@ -15,6 +16,7 @@ def is_objecttype(cls):
class ObjectTypeOptions(FieldsOptions):
def __init__(self, *args, **kwargs):
super(ObjectTypeOptions, self).__init__(*args, **kwargs)
self.interface = False
@ -22,6 +24,7 @@ class ObjectTypeOptions(FieldsOptions):
class ObjectTypeMeta(FieldsClassTypeMeta):
def construct(cls, bases, attrs):
cls = super(ObjectTypeMeta, cls).construct(bases, attrs)
if not cls._meta.abstract:
@ -39,6 +42,7 @@ class ObjectTypeMeta(FieldsClassTypeMeta):
class ObjectType(six.with_metaclass(ObjectTypeMeta, FieldsClassType)):
class Meta:
abstract = True

View File

@ -1,4 +1,5 @@
class Options(object):
def __init__(self, meta=None, **defaults):
self.meta = meta
self.abstract = False

View File

@ -1,7 +1,7 @@
from graphql.core.type import GraphQLScalarType
from .base import ClassType
from ..types.base import MountedType
from .base import ClassType
class Scalar(ClassType, MountedType):

View File

@ -1,6 +1,5 @@
from py.test import raises
from graphene.core.fields import Field
from graphene.core.classtypes import Options

View File

@ -1,18 +1,18 @@
from ..base import ClassType, FieldsClassType
from ...types import Field, String, List, NonNull
from ...schema import Schema
from ...types import Field, List, NonNull, String
from ..base import ClassType, FieldsClassType
def test_classtype_basic():
class Character(ClassType):
'''Character description'''
pass
assert Character._meta.type_name == 'Character'
assert Character._meta.description == 'Character description'
def test_classtype_advanced():
class Character(ClassType):
class Meta:
type_name = 'OtherCharacter'
description = 'OtherCharacter description'
@ -23,7 +23,6 @@ def test_classtype_advanced():
def test_classtype_definition_list():
class Character(ClassType):
'''Character description'''
pass
assert isinstance(Character.List, List)
assert Character.List.of_type == Character
@ -31,7 +30,6 @@ def test_classtype_definition_list():
def test_classtype_definition_nonnull():
class Character(ClassType):
'''Character description'''
pass
assert isinstance(Character.NonNull, NonNull)
assert Character.NonNull.of_type == Character

View File

@ -1,9 +1,9 @@
from py.test import raises
from graphql.core.type import GraphQLInputObjectType
from graphene.core.schema import Schema
from graphene.core.types import String
from ..inputobjecttype import InputObjectType

View File

@ -1,9 +1,9 @@
from py.test import raises
from graphql.core.type import GraphQLInterfaceType, GraphQLObjectType
from py.test import raises
from graphene.core.schema import Schema
from graphene.core.types import String
from ..interface import Interface
from ..objecttype import ObjectType
@ -38,6 +38,7 @@ def test_interface_inheritance_abstract():
pass
class ShouldBeInterface(Character):
class Meta:
abstract = True

View File

@ -1,11 +1,11 @@
from py.test import raises
from graphql.core.type import GraphQLObjectType
from graphene.core.schema import Schema
from graphene.core.types import String
from ..mutation import Mutation
from ...types.argument import ArgumentsGroup
from ..mutation import Mutation
def test_mutation():

View File

@ -1,9 +1,9 @@
from graphql.core.type import GraphQLObjectType
from py.test import raises
from graphql.core.type import GraphQLObjectType
from graphene.core.schema import Schema
from graphene.core.types import Int, String
from graphene.core.types import String
from ..objecttype import ObjectType
from ..uniontype import UnionType

View File

@ -2,6 +2,7 @@ from graphql.core.type import GraphQLUnionType
from graphene.core.schema import Schema
from graphene.core.types import String
from ..objecttype import ObjectType
from ..uniontype import UnionType

View File

@ -1,11 +1,11 @@
import six
from graphql.core.type import GraphQLUnionType
from .base import FieldsOptions, FieldsClassType, FieldsClassTypeMeta
from .base import FieldsClassType, FieldsClassTypeMeta, FieldsOptions
class UnionTypeOptions(FieldsOptions):
def __init__(self, *args, **kwargs):
super(UnionTypeOptions, self).__init__(*args, **kwargs)
self.types = []
@ -19,6 +19,7 @@ class UnionTypeMeta(FieldsClassTypeMeta):
class UnionType(six.with_metaclass(UnionTypeMeta, FieldsClassType)):
class Meta:
abstract = True

View File

@ -10,8 +10,8 @@ from graphql.core.utils.schema_printer import print_schema
from graphene import signals
from .types.base import BaseType
from .classtypes.base import ClassType
from .types.base import BaseType
class GraphQLSchema(_GraphQLSchema):

View File

@ -6,8 +6,8 @@ from graphql.core.type import GraphQLField, GraphQLInputObjectField
from ...utils import to_camel_case
from ..classtypes.base import FieldsClassType
from ..classtypes.mutation import Mutation
from ..classtypes.inputobjecttype import InputObjectType
from ..classtypes.mutation import Mutation
from .argument import ArgumentsGroup, snake_case_args
from .base import LazyType, MountType, OrderedType
from .definitions import NonNull

View File

@ -1,3 +1,3 @@
from ..classtypes import ObjectType, Interface, Mutation, InputObjectType
from ..classtypes import InputObjectType, Interface, Mutation, ObjectType
__all__ = ['ObjectType', 'Interface', 'Mutation', 'InputObjectType']

View File

@ -1,15 +1,15 @@
import inspect
import six
import warnings
from collections import Iterable
from functools import wraps
import six
from graphql_relay.connection.arrayconnection import connection_from_list
from graphql_relay.node.node import to_global_id
from ..core.classtypes import InputObjectType, Interface, Mutation, ObjectType
from ..core.classtypes.mutation import MutationMeta
from ..core.classtypes.interface import InterfaceMeta
from ..core.classtypes.mutation import MutationMeta
from ..core.types import Boolean, Field, List, String
from ..core.types.argument import ArgumentsGroup
from ..core.types.definitions import NonNull
@ -87,6 +87,7 @@ class Connection(ObjectType):
class NodeMeta(InterfaceMeta):
def construct_get_node(cls):
get_node = getattr(cls, 'get_node', None)
assert get_node, 'get_node classmethod not found in %s Node' % cls
@ -145,6 +146,7 @@ class MutationInputType(InputObjectType):
class RelayMutationMeta(MutationMeta):
def construct(cls, *args, **kwargs):
cls = super(RelayMutationMeta, cls).construct(*args, **kwargs)
if not cls._meta.abstract:

View File

@ -2,6 +2,7 @@ try:
from blinker import Signal
except ImportError:
class Signal(object):
def send(self, *args, **kwargs):
pass