Fixing pylint

This commit is contained in:
ariel1899 2020-04-16 14:46:09 -04:00
parent 44679aefc5
commit ed1fdc209e
7 changed files with 32 additions and 44 deletions

View File

@ -1,6 +1,5 @@
from functools import partial, reduce from functools import partial, reduce
import six
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from graphene.types import Field, List from graphene.types import Field, List

View File

@ -8,7 +8,6 @@ from graphene_django.converter import get_choices
from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField
from ..utils import import_single_dispatch from ..utils import import_single_dispatch
singledispatch = import_single_dispatch() singledispatch = import_single_dispatch()

View File

@ -1,7 +1,6 @@
from django import forms from django import forms
from py.test import raises from py.test import raises
import graphene
from graphene import ( from graphene import (
String, String,
Int, Int,

View File

@ -99,6 +99,7 @@ class FormMutationTests(TestCase):
class MyMutation(DjangoFormMutation): class MyMutation(DjangoFormMutation):
class Meta: class Meta:
form_class = MyForm form_class = MyForm
mirror_input = True
class Mutation(ObjectType): class Mutation(ObjectType):
my_mutation = MyMutation.Field() my_mutation = MyMutation.Field()
@ -128,6 +129,7 @@ class FormMutationTests(TestCase):
class MyMutation(DjangoFormMutation): class MyMutation(DjangoFormMutation):
class Meta: class Meta:
form_class = MyForm form_class = MyForm
mirror_input = True
class Mutation(ObjectType): class Mutation(ObjectType):
my_mutation = MyMutation.Field() my_mutation = MyMutation.Field()

View File

@ -11,7 +11,6 @@ from graphene.relay import Node
from .. import registry from .. import registry
from ..settings import graphene_settings from ..settings import graphene_settings
from ..types import DjangoObjectType, DjangoObjectTypeOptions from ..types import DjangoObjectType, DjangoObjectTypeOptions
from ..converter import convert_choice_field_to_enum
from .models import Article as ArticleModel from .models import Article as ArticleModel
from .models import Reporter as ReporterModel from .models import Reporter as ReporterModel
@ -214,7 +213,6 @@ def with_local_registry(func):
@with_local_registry @with_local_registry
def test_django_objecttype_only_fields(): def test_django_objecttype_only_fields():
with pytest.warns(PendingDeprecationWarning): with pytest.warns(PendingDeprecationWarning):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -238,7 +236,6 @@ def test_django_objecttype_fields():
@with_local_registry @with_local_registry
def test_django_objecttype_only_fields_and_fields(): def test_django_objecttype_only_fields_and_fields():
with pytest.raises(Exception): with pytest.raises(Exception):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -260,7 +257,6 @@ def test_django_objecttype_all_fields():
@with_local_registry @with_local_registry
def test_django_objecttype_exclude_fields(): def test_django_objecttype_exclude_fields():
with pytest.warns(PendingDeprecationWarning): with pytest.warns(PendingDeprecationWarning):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -284,7 +280,6 @@ def test_django_objecttype_exclude():
@with_local_registry @with_local_registry
def test_django_objecttype_exclude_fields_and_exclude(): def test_django_objecttype_exclude_fields_and_exclude():
with pytest.raises(Exception): with pytest.raises(Exception):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -295,7 +290,6 @@ def test_django_objecttype_exclude_fields_and_exclude():
@with_local_registry @with_local_registry
def test_django_objecttype_exclude_and_only(): def test_django_objecttype_exclude_and_only():
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -306,14 +300,12 @@ def test_django_objecttype_exclude_and_only():
@with_local_registry @with_local_registry
def test_django_objecttype_fields_exclude_type_checking(): def test_django_objecttype_fields_exclude_type_checking():
with pytest.raises(TypeError): with pytest.raises(TypeError):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
fields = "foo" fields = "foo"
with pytest.raises(TypeError): with pytest.raises(TypeError):
class Reporter2(DjangoObjectType): class Reporter2(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -323,7 +315,6 @@ def test_django_objecttype_fields_exclude_type_checking():
@with_local_registry @with_local_registry
def test_django_objecttype_fields_exist_on_model(): def test_django_objecttype_fields_exist_on_model():
with pytest.warns(UserWarning, match=r"Field name .* doesn't exist"): with pytest.warns(UserWarning, match=r"Field name .* doesn't exist"):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -333,7 +324,6 @@ def test_django_objecttype_fields_exist_on_model():
UserWarning, UserWarning,
match=r"Field name .* matches an attribute on Django model .* but it's not a model field", match=r"Field name .* matches an attribute on Django model .* but it's not a model field",
) as record: ) as record:
class Reporter2(DjangoObjectType): class Reporter2(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -341,7 +331,6 @@ def test_django_objecttype_fields_exist_on_model():
# Don't warn if selecting a custom field # Don't warn if selecting a custom field
with pytest.warns(None) as record: with pytest.warns(None) as record:
class Reporter3(DjangoObjectType): class Reporter3(DjangoObjectType):
custom_field = String() custom_field = String()
@ -358,7 +347,6 @@ def test_django_objecttype_exclude_fields_exist_on_model():
UserWarning, UserWarning,
match=r"Django model .* does not have a field or attribute named .*", match=r"Django model .* does not have a field or attribute named .*",
): ):
class Reporter(DjangoObjectType): class Reporter(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -369,7 +357,6 @@ def test_django_objecttype_exclude_fields_exist_on_model():
UserWarning, UserWarning,
match=r"Excluding the custom field .* on DjangoObjectType .* has no effect.", match=r"Excluding the custom field .* on DjangoObjectType .* has no effect.",
): ):
class Reporter3(DjangoObjectType): class Reporter3(DjangoObjectType):
custom_field = String() custom_field = String()
@ -379,7 +366,6 @@ def test_django_objecttype_exclude_fields_exist_on_model():
# Don't warn on exclude fields # Don't warn on exclude fields
with pytest.warns(None) as record: with pytest.warns(None) as record:
class Reporter4(DjangoObjectType): class Reporter4(DjangoObjectType):
class Meta: class Meta:
model = ReporterModel model = ReporterModel
@ -619,6 +605,7 @@ def test_permission_resolver():
class Info(object): class Info(object):
class Context(object): class Context(object):
user = Viewer() user = Viewer()
context = Context() context = Context()
resolved = PermissionArticle.resolve_headline(MyType, Info()) resolved = PermissionArticle.resolve_headline(MyType, Info())
@ -635,6 +622,7 @@ def test_resolver_without_permission():
class Info(object): class Info(object):
class Context(object): class Context(object):
user = Viewer() user = Viewer()
context = Context() context = Context()
resolved = PermissionArticle.resolve_headline(MyType, Info()) resolved = PermissionArticle.resolve_headline(MyType, Info())
@ -651,6 +639,7 @@ def test_permission_resolver_to_field():
class Info(object): class Info(object):
class Context(object): class Context(object):
user = Viewer() user = Viewer()
context = Context() context = Context()
resolved = PermissionArticle.resolve_extra_field(MyType, Info()) resolved = PermissionArticle.resolve_extra_field(MyType, Info())
@ -667,6 +656,7 @@ def test_resolver_to_field_without_permission():
class Info(object): class Info(object):
class Context(object): class Context(object):
user = Viewer() user = Viewer()
context = Context() context = Context()
resolved = PermissionArticle.resolve_extra_field(MyType, Info()) resolved = PermissionArticle.resolve_extra_field(MyType, Info())

View File

@ -5,7 +5,6 @@ from django.core.exceptions import PermissionDenied
from django.db import models from django.db import models
from django.db.models.manager import Manager from django.db.models.manager import Manager
# from graphene.utils import LazyList # from graphene.utils import LazyList
from graphene.types.resolver import get_default_resolver from graphene.types.resolver import get_default_resolver
from graphene.utils.get_unbound_function import get_unbound_function from graphene.utils.get_unbound_function import get_unbound_function