From 7be5b83fdfdbb06060ea66ed4253437d26469ea9 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Wed, 11 May 2016 23:54:15 -0700 Subject: [PATCH] Fixed PEP8 + Python 3 print --- examples/cookbook_django/cookbook/ingredients/tests.py | 1 - examples/cookbook_django/cookbook/ingredients/views.py | 1 - .../cookbook/recipes/migrations/0001_initial.py | 2 +- examples/cookbook_django/cookbook/recipes/tests.py | 1 - examples/cookbook_django/cookbook/recipes/views.py | 1 - graphene/__init__.py | 3 ++- graphene/contrib/django/debug/tests/test_query.py | 1 - graphene/contrib/django/filter/filterset.py | 2 +- graphene/contrib/django/forms.py | 1 + graphene/contrib/sqlalchemy/tests/test_query.py | 2 +- graphene/core/classtypes/enum.py | 4 ++-- graphene/core/tests/test_old_fields.py | 3 +-- graphene/core/types/custom_scalars.py | 2 +- graphene/core/types/scalars.py | 4 ++-- graphene/core/types/tests/test_custom_scalars.py | 1 - graphene/core/types/tests/test_field.py | 3 +-- graphene/core/types/tests/test_scalars.py | 4 ++-- graphene/relay/fields.py | 2 ++ graphene/relay/types.py | 7 ++++--- graphene/utils/tests/test_str_converter.py | 2 +- 20 files changed, 22 insertions(+), 25 deletions(-) diff --git a/examples/cookbook_django/cookbook/ingredients/tests.py b/examples/cookbook_django/cookbook/ingredients/tests.py index 7ce503c2..49290204 100644 --- a/examples/cookbook_django/cookbook/ingredients/tests.py +++ b/examples/cookbook_django/cookbook/ingredients/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase # Create your tests here. diff --git a/examples/cookbook_django/cookbook/ingredients/views.py b/examples/cookbook_django/cookbook/ingredients/views.py index 91ea44a2..b8e4ee02 100644 --- a/examples/cookbook_django/cookbook/ingredients/views.py +++ b/examples/cookbook_django/cookbook/ingredients/views.py @@ -1,3 +1,2 @@ -from django.shortcuts import render # Create your views here. diff --git a/examples/cookbook_django/cookbook/recipes/migrations/0001_initial.py b/examples/cookbook_django/cookbook/recipes/migrations/0001_initial.py index 2071afc5..338c71a1 100644 --- a/examples/cookbook_django/cookbook/recipes/migrations/0001_initial.py +++ b/examples/cookbook_django/cookbook/recipes/migrations/0001_initial.py @@ -2,8 +2,8 @@ # Generated by Django 1.9 on 2015-12-04 18:20 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/examples/cookbook_django/cookbook/recipes/tests.py b/examples/cookbook_django/cookbook/recipes/tests.py index 7ce503c2..49290204 100644 --- a/examples/cookbook_django/cookbook/recipes/tests.py +++ b/examples/cookbook_django/cookbook/recipes/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase # Create your tests here. diff --git a/examples/cookbook_django/cookbook/recipes/views.py b/examples/cookbook_django/cookbook/recipes/views.py index 91ea44a2..b8e4ee02 100644 --- a/examples/cookbook_django/cookbook/recipes/views.py +++ b/examples/cookbook_django/cookbook/recipes/views.py @@ -1,3 +1,2 @@ -from django.shortcuts import render # Create your views here. diff --git a/graphene/__init__.py b/graphene/__init__.py index f4683c40..a4eb6299 100644 --- a/graphene/__init__.py +++ b/graphene/__init__.py @@ -66,4 +66,5 @@ __all__ = [ 'ListField', 'NonNullField', 'FloatField', - 'resolve_only_args'] + 'resolve_only_args', + 'with_context'] diff --git a/graphene/contrib/django/debug/tests/test_query.py b/graphene/contrib/django/debug/tests/test_query.py index ba7c07c7..c512d6ad 100644 --- a/graphene/contrib/django/debug/tests/test_query.py +++ b/graphene/contrib/django/debug/tests/test_query.py @@ -149,7 +149,6 @@ def test_should_query_connection(): schema = graphene.Schema(query=Query, plugins=[DjangoDebugPlugin()]) result = schema.execute(query) assert not result.errors - print result.data['__debug']['sql'] assert result.data['allReporters'] == expected['allReporters'] assert 'COUNT' in result.data['__debug']['sql'][0]['rawSql'] query = str(Reporter.objects.all()[:1].query) diff --git a/graphene/contrib/django/filter/filterset.py b/graphene/contrib/django/filter/filterset.py index 482dc8f7..6b9c8ac9 100644 --- a/graphene/contrib/django/filter/filterset.py +++ b/graphene/contrib/django/filter/filterset.py @@ -4,10 +4,10 @@ from django.db import models 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 graphene.contrib.django.forms import (GlobalIDFormField, GlobalIDMultipleChoiceField) +from graphql_relay.node.node import from_global_id class GlobalIDFilter(Filter): diff --git a/graphene/contrib/django/forms.py b/graphene/contrib/django/forms.py index 591236cb..8f8d0305 100644 --- a/graphene/contrib/django/forms.py +++ b/graphene/contrib/django/forms.py @@ -3,6 +3,7 @@ import binascii from django.core.exceptions import ValidationError from django.forms import CharField, Field, IntegerField, MultipleChoiceField from django.utils.translation import ugettext_lazy as _ + from graphql_relay import from_global_id diff --git a/graphene/contrib/sqlalchemy/tests/test_query.py b/graphene/contrib/sqlalchemy/tests/test_query.py index ce66d196..da8f8e11 100644 --- a/graphene/contrib/sqlalchemy/tests/test_query.py +++ b/graphene/contrib/sqlalchemy/tests/test_query.py @@ -7,7 +7,7 @@ from graphene import relay from graphene.contrib.sqlalchemy import (SQLAlchemyConnectionField, SQLAlchemyNode, SQLAlchemyObjectType) -from .models import Article, Base, Reporter, Editor +from .models import Article, Base, Editor, Reporter db = create_engine('sqlite:///test_sqlalchemy.sqlite3') diff --git a/graphene/core/classtypes/enum.py b/graphene/core/classtypes/enum.py index bb9f661c..97c8fe9f 100644 --- a/graphene/core/classtypes/enum.py +++ b/graphene/core/classtypes/enum.py @@ -1,9 +1,9 @@ import six from graphql.type import GraphQLEnumType, GraphQLEnumValue -from .base import ClassTypeMeta, ClassType -from ..types.base import MountedType from ...utils.enum import Enum as PyEnum +from ..types.base import MountedType +from .base import ClassType, ClassTypeMeta class EnumMeta(ClassTypeMeta): diff --git a/graphene/core/tests/test_old_fields.py b/graphene/core/tests/test_old_fields.py index 86ca805d..a1d8ac60 100644 --- a/graphene/core/tests/test_old_fields.py +++ b/graphene/core/tests/test_old_fields.py @@ -1,6 +1,5 @@ from graphql.type import (GraphQLBoolean, GraphQLField, GraphQLFloat, - GraphQLID, GraphQLInt, GraphQLNonNull, - GraphQLString) + GraphQLID, GraphQLInt, GraphQLNonNull, GraphQLString) from py.test import raises from graphene.core.fields import (BooleanField, Field, FloatField, IDField, diff --git a/graphene/core/types/custom_scalars.py b/graphene/core/types/custom_scalars.py index 55580a5d..bd33df76 100644 --- a/graphene/core/types/custom_scalars.py +++ b/graphene/core/types/custom_scalars.py @@ -1,6 +1,6 @@ import json -import iso8601 +import iso8601 from graphql.language import ast from ...core.classtypes.scalar import Scalar diff --git a/graphene/core/types/scalars.py b/graphene/core/types/scalars.py index 12ea3d14..4f178cb9 100644 --- a/graphene/core/types/scalars.py +++ b/graphene/core/types/scalars.py @@ -1,5 +1,5 @@ -from graphql.type import (GraphQLBoolean, GraphQLFloat, GraphQLID, - GraphQLInt, GraphQLString) +from graphql.type import (GraphQLBoolean, GraphQLFloat, GraphQLID, GraphQLInt, + GraphQLString) from .base import MountedType diff --git a/graphene/core/types/tests/test_custom_scalars.py b/graphene/core/types/tests/test_custom_scalars.py index be0f77a9..28012b36 100644 --- a/graphene/core/types/tests/test_custom_scalars.py +++ b/graphene/core/types/tests/test_custom_scalars.py @@ -1,5 +1,4 @@ import iso8601 - from graphql.language.ast import StringValue from ..custom_scalars import DateTime diff --git a/graphene/core/types/tests/test_field.py b/graphene/core/types/tests/test_field.py index e2ef15e9..2d4301ef 100644 --- a/graphene/core/types/tests/test_field.py +++ b/graphene/core/types/tests/test_field.py @@ -1,5 +1,4 @@ -from graphql.type import (GraphQLField, GraphQLInputObjectField, - GraphQLString) +from graphql.type import GraphQLField, GraphQLInputObjectField, GraphQLString from graphene.core.schema import Schema from graphene.core.types import InputObjectType, ObjectType diff --git a/graphene/core/types/tests/test_scalars.py b/graphene/core/types/tests/test_scalars.py index acd657d8..124bb8c4 100644 --- a/graphene/core/types/tests/test_scalars.py +++ b/graphene/core/types/tests/test_scalars.py @@ -1,5 +1,5 @@ -from graphql.type import (GraphQLBoolean, GraphQLFloat, GraphQLID, - GraphQLInt, GraphQLString) +from graphql.type import (GraphQLBoolean, GraphQLFloat, GraphQLID, GraphQLInt, + GraphQLString) from graphene.core.schema import Schema diff --git a/graphene/relay/fields.py b/graphene/relay/fields.py index 7466de8f..da9d4af7 100644 --- a/graphene/relay/fields.py +++ b/graphene/relay/fields.py @@ -1,4 +1,5 @@ import six + from graphql_relay.node.node import from_global_id from ..core.fields import Field @@ -6,6 +7,7 @@ from ..core.types.definitions import NonNull from ..core.types.scalars import ID, Int, String from ..utils import with_context + class ConnectionField(Field): def __init__(self, type, resolver=None, description='', diff --git a/graphene/relay/types.py b/graphene/relay/types.py index accde95e..6df9d7f6 100644 --- a/graphene/relay/types.py +++ b/graphene/relay/types.py @@ -4,6 +4,7 @@ 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 @@ -123,10 +124,10 @@ class NodeMeta(InterfaceMeta): def wrapped_node(id, context=None, info=None): node_args = [id, info, context] if has_context(get_node): - return get_node(*node_args[:get_node_num_args-1], context=context) - if get_node_num_args-1 == 0: + return get_node(*node_args[:get_node_num_args - 1], context=context) + if get_node_num_args - 1 == 0: return get_node(id) - return get_node(*node_args[:get_node_num_args-1]) + return get_node(*node_args[:get_node_num_args - 1]) node_func = wrapped_node setattr(cls, 'get_node', node_func) diff --git a/graphene/utils/tests/test_str_converter.py b/graphene/utils/tests/test_str_converter.py index 83e3c2fa..1e4880c2 100644 --- a/graphene/utils/tests/test_str_converter.py +++ b/graphene/utils/tests/test_str_converter.py @@ -1,5 +1,5 @@ # coding: utf-8 -from ..str_converters import to_camel_case, to_snake_case, to_const +from ..str_converters import to_camel_case, to_const, to_snake_case def test_snake_case():