mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-04 20:33:12 +03:00
Fixing pylint
This commit is contained in:
parent
44679aefc5
commit
ed1fdc209e
|
@ -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
|
||||||
|
|
||||||
|
@ -141,16 +140,16 @@ class DjangoConnectionField(ConnectionField):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def connection_resolver(
|
def connection_resolver(
|
||||||
cls,
|
cls,
|
||||||
resolver,
|
resolver,
|
||||||
connection,
|
connection,
|
||||||
default_manager,
|
default_manager,
|
||||||
queryset_resolver,
|
queryset_resolver,
|
||||||
max_limit,
|
max_limit,
|
||||||
enforce_first_or_last,
|
enforce_first_or_last,
|
||||||
root,
|
root,
|
||||||
info,
|
info,
|
||||||
**args
|
**args
|
||||||
):
|
):
|
||||||
first = args.get("first")
|
first = args.get("first")
|
||||||
last = args.get("last")
|
last = args.get("last")
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ def fields_for_form(form, only_fields, exclude_fields):
|
||||||
for name, field in form.fields.items():
|
for name, field in form.fields.items():
|
||||||
is_not_in_only = only_fields and name not in only_fields
|
is_not_in_only = only_fields and name not in only_fields
|
||||||
is_excluded = (
|
is_excluded = (
|
||||||
name
|
name
|
||||||
in exclude_fields # or
|
in exclude_fields # or
|
||||||
# name in already_created_fields
|
# name in already_created_fields
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class DjangoFormMutation(BaseDjangoFormMutation):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init_subclass_with_meta__(
|
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:
|
if not form_class:
|
||||||
|
@ -122,13 +122,13 @@ class DjangoModelFormMutation(BaseDjangoFormMutation):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init_subclass_with_meta__(
|
def __init_subclass_with_meta__(
|
||||||
cls,
|
cls,
|
||||||
form_class=None,
|
form_class=None,
|
||||||
model=None,
|
model=None,
|
||||||
return_field_name=None,
|
return_field_name=None,
|
||||||
only_fields=(),
|
only_fields=(),
|
||||||
exclude_fields=(),
|
exclude_fields=(),
|
||||||
**options
|
**options
|
||||||
):
|
):
|
||||||
|
|
||||||
if not form_class:
|
if not form_class:
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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,17 +315,15 @@ 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
|
||||||
fields = ["first_name", "foo", "email"]
|
fields = ["first_name", "foo", "email"]
|
||||||
|
|
||||||
with pytest.warns(
|
with pytest.warns(
|
||||||
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()
|
||||||
|
|
||||||
|
@ -355,10 +344,9 @@ def test_django_objecttype_fields_exist_on_model():
|
||||||
@with_local_registry
|
@with_local_registry
|
||||||
def test_django_objecttype_exclude_fields_exist_on_model():
|
def test_django_objecttype_exclude_fields_exist_on_model():
|
||||||
with pytest.warns(
|
with pytest.warns(
|
||||||
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
|
||||||
|
@ -366,10 +354,9 @@ def test_django_objecttype_exclude_fields_exist_on_model():
|
||||||
|
|
||||||
# Don't warn if selecting a custom field
|
# Don't warn if selecting a custom field
|
||||||
with pytest.warns(
|
with pytest.warns(
|
||||||
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())
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user