diff --git a/graphene_django/fields.py b/graphene_django/fields.py index c082930..bc3e597 100644 --- a/graphene_django/fields.py +++ b/graphene_django/fields.py @@ -1,6 +1,5 @@ from functools import partial, reduce -import six from django.db.models.query import QuerySet from graphene.types import Field, List @@ -141,16 +140,16 @@ class DjangoConnectionField(ConnectionField): @classmethod def connection_resolver( - cls, - resolver, - connection, - default_manager, - queryset_resolver, - max_limit, - enforce_first_or_last, - root, - info, - **args + cls, + resolver, + connection, + default_manager, + queryset_resolver, + max_limit, + enforce_first_or_last, + root, + info, + **args ): first = args.get("first") last = args.get("last") diff --git a/graphene_django/forms/converter.py b/graphene_django/forms/converter.py index 96075f8..f83c45f 100644 --- a/graphene_django/forms/converter.py +++ b/graphene_django/forms/converter.py @@ -8,7 +8,6 @@ from graphene_django.converter import get_choices from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField from ..utils import import_single_dispatch - singledispatch = import_single_dispatch() diff --git a/graphene_django/forms/mutation.py b/graphene_django/forms/mutation.py index fd06111..c78e110 100644 --- a/graphene_django/forms/mutation.py +++ b/graphene_django/forms/mutation.py @@ -22,8 +22,8 @@ def fields_for_form(form, only_fields, exclude_fields): for name, field in form.fields.items(): is_not_in_only = only_fields and name not in only_fields is_excluded = ( - name - in exclude_fields # or + name + in exclude_fields # or # name in already_created_fields ) @@ -81,7 +81,7 @@ class DjangoFormMutation(BaseDjangoFormMutation): @classmethod def __init_subclass_with_meta__( - cls, form_class=None, mirror_input=False, only_fields=(), exclude_fields=(), **options + cls, form_class=None, mirror_input=False, only_fields=(), exclude_fields=(), **options ): if not form_class: @@ -122,13 +122,13 @@ class DjangoModelFormMutation(BaseDjangoFormMutation): @classmethod def __init_subclass_with_meta__( - cls, - form_class=None, - model=None, - return_field_name=None, - only_fields=(), - exclude_fields=(), - **options + cls, + form_class=None, + model=None, + return_field_name=None, + only_fields=(), + exclude_fields=(), + **options ): if not form_class: diff --git a/graphene_django/forms/tests/test_converter.py b/graphene_django/forms/tests/test_converter.py index e76c5c2..8251491 100644 --- a/graphene_django/forms/tests/test_converter.py +++ b/graphene_django/forms/tests/test_converter.py @@ -1,7 +1,6 @@ from django import forms from py.test import raises -import graphene from graphene import ( String, Int, diff --git a/graphene_django/forms/tests/test_mutation.py b/graphene_django/forms/tests/test_mutation.py index 6208f96..aaf215b 100644 --- a/graphene_django/forms/tests/test_mutation.py +++ b/graphene_django/forms/tests/test_mutation.py @@ -99,6 +99,7 @@ class FormMutationTests(TestCase): class MyMutation(DjangoFormMutation): class Meta: form_class = MyForm + mirror_input = True class Mutation(ObjectType): my_mutation = MyMutation.Field() @@ -128,6 +129,7 @@ class FormMutationTests(TestCase): class MyMutation(DjangoFormMutation): class Meta: form_class = MyForm + mirror_input = True class Mutation(ObjectType): my_mutation = MyMutation.Field() diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py index 16c23b1..830b1fa 100644 --- a/graphene_django/tests/test_types.py +++ b/graphene_django/tests/test_types.py @@ -11,7 +11,6 @@ from graphene.relay import Node from .. import registry from ..settings import graphene_settings from ..types import DjangoObjectType, DjangoObjectTypeOptions -from ..converter import convert_choice_field_to_enum from .models import Article as ArticleModel from .models import Reporter as ReporterModel @@ -214,7 +213,6 @@ def with_local_registry(func): @with_local_registry def test_django_objecttype_only_fields(): with pytest.warns(PendingDeprecationWarning): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel @@ -238,7 +236,6 @@ def test_django_objecttype_fields(): @with_local_registry def test_django_objecttype_only_fields_and_fields(): with pytest.raises(Exception): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel @@ -260,7 +257,6 @@ def test_django_objecttype_all_fields(): @with_local_registry def test_django_objecttype_exclude_fields(): with pytest.warns(PendingDeprecationWarning): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel @@ -284,7 +280,6 @@ def test_django_objecttype_exclude(): @with_local_registry def test_django_objecttype_exclude_fields_and_exclude(): with pytest.raises(Exception): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel @@ -295,7 +290,6 @@ def test_django_objecttype_exclude_fields_and_exclude(): @with_local_registry def test_django_objecttype_exclude_and_only(): with pytest.raises(AssertionError): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel @@ -306,14 +300,12 @@ def test_django_objecttype_exclude_and_only(): @with_local_registry def test_django_objecttype_fields_exclude_type_checking(): with pytest.raises(TypeError): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel fields = "foo" with pytest.raises(TypeError): - class Reporter2(DjangoObjectType): class Meta: model = ReporterModel @@ -323,17 +315,15 @@ def test_django_objecttype_fields_exclude_type_checking(): @with_local_registry def test_django_objecttype_fields_exist_on_model(): with pytest.warns(UserWarning, match=r"Field name .* doesn't exist"): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel fields = ["first_name", "foo", "email"] with pytest.warns( - UserWarning, - match=r"Field name .* matches an attribute on Django model .* but it's not a model field", + UserWarning, + match=r"Field name .* matches an attribute on Django model .* but it's not a model field", ) as record: - class Reporter2(DjangoObjectType): class Meta: model = ReporterModel @@ -341,7 +331,6 @@ def test_django_objecttype_fields_exist_on_model(): # Don't warn if selecting a custom field with pytest.warns(None) as record: - class Reporter3(DjangoObjectType): custom_field = String() @@ -355,10 +344,9 @@ def test_django_objecttype_fields_exist_on_model(): @with_local_registry def test_django_objecttype_exclude_fields_exist_on_model(): with pytest.warns( - UserWarning, - match=r"Django model .* does not have a field or attribute named .*", + UserWarning, + match=r"Django model .* does not have a field or attribute named .*", ): - class Reporter(DjangoObjectType): class Meta: model = ReporterModel @@ -366,10 +354,9 @@ def test_django_objecttype_exclude_fields_exist_on_model(): # Don't warn if selecting a custom field with pytest.warns( - UserWarning, - match=r"Excluding the custom field .* on DjangoObjectType .* has no effect.", + UserWarning, + match=r"Excluding the custom field .* on DjangoObjectType .* has no effect.", ): - class Reporter3(DjangoObjectType): custom_field = String() @@ -379,7 +366,6 @@ def test_django_objecttype_exclude_fields_exist_on_model(): # Don't warn on exclude fields with pytest.warns(None) as record: - class Reporter4(DjangoObjectType): class Meta: model = ReporterModel @@ -619,6 +605,7 @@ def test_permission_resolver(): class Info(object): class Context(object): user = Viewer() + context = Context() resolved = PermissionArticle.resolve_headline(MyType, Info()) @@ -635,6 +622,7 @@ def test_resolver_without_permission(): class Info(object): class Context(object): user = Viewer() + context = Context() resolved = PermissionArticle.resolve_headline(MyType, Info()) @@ -651,6 +639,7 @@ def test_permission_resolver_to_field(): class Info(object): class Context(object): user = Viewer() + context = Context() resolved = PermissionArticle.resolve_extra_field(MyType, Info()) @@ -667,6 +656,7 @@ def test_resolver_to_field_without_permission(): class Info(object): class Context(object): user = Viewer() + context = Context() resolved = PermissionArticle.resolve_extra_field(MyType, Info()) diff --git a/graphene_django/utils/utils.py b/graphene_django/utils/utils.py index f46c705..d148932 100644 --- a/graphene_django/utils/utils.py +++ b/graphene_django/utils/utils.py @@ -5,7 +5,6 @@ from django.core.exceptions import PermissionDenied from django.db import models from django.db.models.manager import Manager - # from graphene.utils import LazyList from graphene.types.resolver import get_default_resolver from graphene.utils.get_unbound_function import get_unbound_function