mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-10 19:57:15 +03:00
Improved PEP8 syntax
This commit is contained in:
parent
d11719507c
commit
70dbd4b512
|
@ -1,7 +1,6 @@
|
|||
from django.conf.urls import include, url
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
|
||||
from cookbook.schema import schema
|
||||
from graphene_django.views import GraphQLView
|
||||
|
||||
urlpatterns = [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import graphene
|
||||
from graphene import Schema, relay, resolve_only_args
|
||||
from graphene_django import DjangoObjectType, DjangoConnectionField
|
||||
from graphene_django import DjangoConnectionField, DjangoObjectType
|
||||
|
||||
from .data import (create_ship, get_empire, get_faction, get_rebels, get_ship,
|
||||
get_ships)
|
||||
|
|
|
@ -32,7 +32,6 @@ else:
|
|||
class CommandArguments(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
from django.conf import settings
|
||||
parser.add_argument(
|
||||
'--schema',
|
||||
type=str,
|
||||
|
@ -57,7 +56,6 @@ class Command(CommandArguments):
|
|||
json.dump(schema_dict, outfile)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
from django.conf import settings
|
||||
options_schema = options.get('schema')
|
||||
if options_schema:
|
||||
schema = importlib.import_module(options_schema)
|
||||
|
|
|
@ -43,7 +43,6 @@ IMPORT_STRINGS = (
|
|||
)
|
||||
|
||||
|
||||
|
||||
def perform_import(val, setting_name):
|
||||
"""
|
||||
If the given setting is a string import notation,
|
||||
|
@ -82,6 +81,7 @@ class GrapheneSettings(object):
|
|||
Any setting with string import paths will be automatically resolved
|
||||
and return the class, rather than the string literal.
|
||||
"""
|
||||
|
||||
def __init__(self, user_settings=None, defaults=None, import_strings=None):
|
||||
if user_settings:
|
||||
self._user_settings = user_settings
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import graphene
|
||||
from graphene import Schema, ObjectType, relay
|
||||
|
||||
from ..types import DjangoObjectType
|
||||
from .models import Article, Reporter
|
||||
from graphene import ObjectType, Schema
|
||||
|
||||
|
||||
class QueryRoot(ObjectType):
|
||||
|
@ -10,10 +7,10 @@ class QueryRoot(ObjectType):
|
|||
thrower = graphene.String(required=True)
|
||||
request = graphene.String(required=True)
|
||||
test = graphene.String(who=graphene.String())
|
||||
|
||||
|
||||
def resolve_thrower(self, args, context, info):
|
||||
raise Exception("Throws!")
|
||||
|
||||
|
||||
def resolve_request(self, args, context, info):
|
||||
request = context
|
||||
return request.GET.get('q')
|
||||
|
|
|
@ -19,7 +19,6 @@ from .models import Article, Film, FilmDetails, Reporter
|
|||
# from graphene.core.types.custom_scalars import DateTime, JSONString
|
||||
|
||||
|
||||
|
||||
def assert_conversion(django_field, graphene_field, *args, **kwargs):
|
||||
field = django_field(help_text='Custom Help Text', *args, **kwargs)
|
||||
graphene_type = convert_django_field(field)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
try:
|
||||
from urllib import urlencode
|
||||
except ImportError:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.conf.urls import url
|
||||
|
||||
from ..views import GraphQLView
|
||||
|
||||
urlpatterns = [
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.conf.urls import url
|
||||
|
||||
from graphql_django_view import GraphQLView
|
||||
|
||||
from .schema_view import schema
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
import re
|
||||
import json
|
||||
import six
|
||||
import re
|
||||
|
||||
import six
|
||||
from django.http import HttpResponse, HttpResponseNotAllowed
|
||||
from django.http.response import HttpResponseBadRequest
|
||||
from django.views.generic import View
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import View
|
||||
|
||||
from graphql import Source, parse, execute, validate
|
||||
from graphql.error import GraphQLError, format_error as format_graphql_error
|
||||
from graphql import Source, execute, parse, validate
|
||||
from graphql.error import format_error as format_graphql_error
|
||||
from graphql.error import GraphQLError
|
||||
from graphql.execution import ExecutionResult
|
||||
from graphql.type.schema import GraphQLSchema
|
||||
from graphql.execution.middleware import MiddlewareManager
|
||||
from graphql.type.schema import GraphQLSchema
|
||||
from graphql.utils.get_operation_ast import get_operation_ast
|
||||
|
||||
from .settings import graphene_settings
|
||||
|
||||
|
||||
class HttpError(Exception):
|
||||
|
||||
def __init__(self, response, message=None, *args, **kwargs):
|
||||
self.response = response
|
||||
self.message = message = message or response.content.decode()
|
||||
|
@ -192,7 +194,7 @@ class GraphQLView(View):
|
|||
if operation_ast and operation_ast.operation != 'query':
|
||||
if show_graphiql:
|
||||
return None
|
||||
|
||||
|
||||
raise HttpError(HttpResponseNotAllowed(
|
||||
['POST'], 'Can only perform a {} operation from a POST request.'.format(operation_ast.operation)
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue
Block a user