Fixed PEP8 errors

This commit is contained in:
Syrus Akbary 2016-01-13 18:38:53 -08:00
parent 2acd8691cf
commit 112006c211
12 changed files with 25 additions and 16 deletions

View File

@ -4,7 +4,7 @@ from ...core.types.base import FieldType
from ...core.types.definitions import List from ...core.types.definitions import List
from ...relay import ConnectionField from ...relay import ConnectionField
from ...relay.utils import is_node from ...relay.utils import is_node
from .utils import get_type_for_model, maybe_queryset, DJANGO_FILTER_INSTALLED from .utils import DJANGO_FILTER_INSTALLED, get_type_for_model, maybe_queryset
class DjangoConnectionField(ConnectionField): class DjangoConnectionField(ConnectionField):

View File

@ -2,10 +2,10 @@ import six
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.utils.text import capfirst from django.utils.text import capfirst
from django_filters import Filter, MultipleChoiceFilter
from django_filters.filterset import FilterSet, FilterSetMetaclass
from graphql_relay.node.node import from_global_id from graphql_relay.node.node import from_global_id
from django_filters import Filter, MultipleChoiceFilter
from django_filters.filterset import FilterSet, FilterSetMetaclass
from graphene.contrib.django.forms import (GlobalIDFormField, from graphene.contrib.django.forms import (GlobalIDFormField,
GlobalIDMultipleChoiceField) GlobalIDMultipleChoiceField)

View File

@ -1,5 +1,4 @@
import django_filters import django_filters
from graphene.contrib.django.tests.models import Article, Pet, Reporter from graphene.contrib.django.tests.models import Article, Pet, Reporter

View File

@ -1,7 +1,7 @@
import importlib import importlib
import json import json
from optparse import make_option
from distutils.version import StrictVersion from distutils.version import StrictVersion
from optparse import make_option
from django import get_version as get_django_version from django import get_version as get_django_version
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
@ -28,6 +28,7 @@ if LT_DJANGO_1_8:
) )
else: else:
class CommandArguments(BaseCommand): class CommandArguments(BaseCommand):
def add_arguments(self, parser): def add_arguments(self, parser):
from django.conf import settings from django.conf import settings
parser.add_argument( parser.add_argument(

View File

@ -1,8 +1,7 @@
from django.core import management
from mock import patch from mock import patch
from six import StringIO from six import StringIO
from django.core import management
@patch('graphene.contrib.django.management.commands.graphql_schema.Command.save_file') @patch('graphene.contrib.django.management.commands.graphql_schema.Command.save_file')
def test_generate_file_on_call_graphql_schema(savefile_mock, settings): def test_generate_file_on_call_graphql_schema(savefile_mock, settings):

View File

@ -1,7 +1,7 @@
from py.test import raises from py.test import raises
from tests.utils import assert_equal_lists
from graphene.contrib.django import DjangoObjectType from graphene.contrib.django import DjangoObjectType
from tests.utils import assert_equal_lists
from .models import Reporter from .models import Reporter

View File

@ -1,12 +1,12 @@
from graphql.core.type import GraphQLObjectType from graphql.core.type import GraphQLObjectType
from mock import patch from mock import patch
from tests.utils import assert_equal_lists
from graphene import Schema from graphene import Schema
from graphene.contrib.django.types import DjangoNode, DjangoObjectType from graphene.contrib.django.types import DjangoNode, DjangoObjectType
from graphene.core.fields import Field from graphene.core.fields import Field
from graphene.core.types.scalars import Int from graphene.core.types.scalars import Int
from graphene.relay.fields import GlobalIDField from graphene.relay.fields import GlobalIDField
from tests.utils import assert_equal_lists
from .models import Article, Reporter from .models import Article, Reporter

View File

@ -1,10 +1,10 @@
from graphql.core import graphql from graphql.core import graphql
from py.test import raises from py.test import raises
from tests.utils import assert_equal_lists
from graphene import Interface, List, ObjectType, Schema, String from graphene import Interface, List, ObjectType, Schema, String
from graphene.core.fields import Field from graphene.core.fields import Field
from graphene.core.types.base import LazyType from graphene.core.types.base import LazyType
from tests.utils import assert_equal_lists
schema = Schema(name='My own schema') schema = Schema(name='My own schema')

View File

@ -48,6 +48,7 @@ def test_to_arguments_wrong_type():
def test_snake_case_args(): def test_snake_case_args():
resolver = lambda instance, args, info: args['my_arg']['inner_arg'] def resolver(instance, args, info):
return args['my_arg']['inner_arg']
r = snake_case_args(resolver) r = snake_case_args(resolver)
assert r(None, {'myArg': {'innerArg': 3}}, None) == 3 assert r(None, {'myArg': {'innerArg': 3}}, None) == 3

View File

@ -25,7 +25,9 @@ def test_orderedtype_different():
@patch('graphene.core.types.field.Field') @patch('graphene.core.types.field.Field')
def test_type_as_field_called(Field): def test_type_as_field_called(Field):
resolver = lambda x: x def resolver(x):
return x
a = MountedType(2, description='A', resolver=resolver) a = MountedType(2, description='A', resolver=resolver)
a.as_field() a.as_field()
Field.assert_called_with( Field.assert_called_with(
@ -45,7 +47,8 @@ def test_type_as_argument_called(Argument):
def test_type_as_field(): def test_type_as_field():
resolver = lambda x: x def resolver(x):
return x
class MyObjectType(ObjectType): class MyObjectType(ObjectType):
t = MountedType(description='A', resolver=resolver) t = MountedType(description='A', resolver=resolver)

View File

@ -11,7 +11,8 @@ from ..scalars import String
def test_field_internal_type(): def test_field_internal_type():
resolver = lambda *args: 'RESOLVED' def resolver(*args):
return 'RESOLVED'
field = Field(String(), description='My argument', resolver=resolver) field = Field(String(), description='My argument', resolver=resolver)
@ -132,7 +133,8 @@ def test_inputfield_internal_type():
def test_field_resolve_argument(): def test_field_resolve_argument():
resolver = lambda instance, args, info: args.get('first_name') def resolver(instance, args, info):
return args.get('first_name')
field = Field(String(), first_name=String(), description='My argument', resolver=resolver) field = Field(String(), first_name=String(), description='My argument', resolver=resolver)

View File

@ -2,7 +2,11 @@ from ..resolve_only_args import resolve_only_args
def test_resolve_only_args(): def test_resolve_only_args():
def resolver(*args, **kwargs):
return kwargs
my_data = {'one': 1, 'two': 2} my_data = {'one': 1, 'two': 2}
resolver = lambda *args, **kwargs: kwargs
wrapped = resolve_only_args(resolver) wrapped = resolve_only_args(resolver)
assert wrapped(None, my_data, None) == my_data assert wrapped(None, my_data, None) == my_data