Skip to content

Commit 0fd5d6d

Browse files
author
Daniel Gallagher
committed
Run pre-commit on all files
1 parent 415a78a commit 0fd5d6d

39 files changed

+122
-123
lines changed

graphql/backend/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from ..pyutils.cached_property import cached_property
2-
from ..language import ast
3-
41
from abc import ABCMeta, abstractmethod
2+
53
import six
64

5+
from ..language import ast
6+
from ..pyutils.cached_property import cached_property
7+
78

89
class GraphQLBackend(six.with_metaclass(ABCMeta)):
910
@abstractmethod

graphql/backend/cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from hashlib import sha1
2+
23
from six import string_types
3-
from ..type import GraphQLSchema
44

5+
from ..type import GraphQLSchema
56
from .base import GraphQLBackend
67

78
_cached_schemas = {}

graphql/backend/compiled.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from six import string_types
2+
23
from .base import GraphQLDocument
34

45

graphql/backend/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from functools import partial
2+
23
from six import string_types
34

4-
from ..execution import execute, ExecutionResult
5-
from ..language.base import parse, print_ast
5+
from ..execution import ExecutionResult, execute
66
from ..language import ast
7+
from ..language.base import parse, print_ast
78
from ..validation import validate
8-
99
from .base import GraphQLBackend, GraphQLDocument
1010

1111

graphql/backend/quiver_cloud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"You can install it using: pip install requests"
77
)
88

9-
from ..utils.schema_printer import print_schema
9+
from six import urlparse
1010

11+
from ..utils.schema_printer import print_schema
1112
from .base import GraphQLBackend
1213
from .compiled import GraphQLCompiledDocument
1314

14-
from six import urlparse
1515

1616
GRAPHQL_QUERY = """
1717
mutation($schemaDsl: String!, $query: String!) {

graphql/backend/tests/schema.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from graphql.type import (GraphQLField, GraphQLObjectType,
2-
GraphQLSchema, GraphQLString)
3-
1+
from graphql.type import (GraphQLField, GraphQLObjectType, GraphQLSchema,
2+
GraphQLString)
43

54
Query = GraphQLObjectType('Query', lambda: {
65
'hello': GraphQLField(GraphQLString, resolver=lambda *_: "World"),

graphql/backend/tests/test_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
2-
from .. import get_default_backend, set_default_backend, GraphQLCoreBackend
2+
3+
from .. import GraphQLCoreBackend, get_default_backend, set_default_backend
34

45

56
def test_get_default_backend_returns_core_by_default():

graphql/backend/tests/test_cache.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# -*- coding: utf-8 -*-
33
"""Tests for `graphql.backend.cache` module."""
44

5+
from graphql.execution.executors.sync import SyncExecutor
6+
57
import pytest
68

7-
from ..core import GraphQLCoreBackend
89
from ..cache import GraphQLCachedBackend
9-
from graphql.execution.executors.sync import SyncExecutor
10+
from ..core import GraphQLCoreBackend
1011
from .schema import schema
1112

1213

graphql/backend/tests/test_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# -*- coding: utf-8 -*-
33
"""Tests for `graphql.backend.core` module."""
44

5-
import pytest
65
from graphql.execution.executors.sync import SyncExecutor
76

7+
import pytest
8+
89
from ..base import GraphQLBackend, GraphQLDocument
910
from ..core import GraphQLCoreBackend
1011
from .schema import schema

graphql/backend/tests/test_decider.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import pytest
66

77
from ..base import GraphQLBackend, GraphQLDocument
8-
from ..core import GraphQLCoreBackend
98
from ..cache import GraphQLCachedBackend
9+
from ..core import GraphQLCoreBackend
1010
from ..decider import GraphQLDeciderBackend
11-
1211
from .schema import schema
1312

1413

graphql/error/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import six
2+
23
from ..language.location import get_location
34

45

graphql/error/tests/test_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import pytest
21
import traceback
32

43
from graphql.execution import execute
54
from graphql.language.parser import parse
65
from graphql.type import (GraphQLField, GraphQLObjectType, GraphQLSchema,
76
GraphQLString)
87

8+
import pytest
9+
910

1011
def test_raise():
1112
ast = parse('query Example { a }')

graphql/execution/base.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# We keep the following imports to preserve compatibility
2-
from .utils import (
3-
ExecutionContext,
4-
SubscriberExecutionContext,
5-
get_operation_root_type,
6-
collect_fields,
7-
should_include_node,
8-
does_fragment_condition_match,
9-
get_field_entry_key,
10-
default_resolve_fn,
11-
get_field_def
12-
)
2+
from .utils import (ExecutionContext, SubscriberExecutionContext,
3+
collect_fields, default_resolve_fn,
4+
does_fragment_condition_match, get_field_def,
5+
get_field_entry_key, get_operation_root_type,
6+
should_include_node)
137

148

159
class ExecutionResult(object):

graphql/execution/executor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
import logging
44
import sys
55
import warnings
6-
from rx import Observable
76

7+
from promise import Promise, is_thenable, promise_for_dict
8+
from rx import Observable
89
from six import string_types
9-
from promise import Promise, promise_for_dict, is_thenable
1010

1111
from ..error import GraphQLError, GraphQLLocatedError
1212
from ..pyutils.default_ordered_dict import DefaultOrderedDict
1313
from ..pyutils.ordereddict import OrderedDict
14-
from ..utils.undefined import Undefined
1514
from ..type import (GraphQLEnumType, GraphQLInterfaceType, GraphQLList,
1615
GraphQLNonNull, GraphQLObjectType, GraphQLScalarType,
1716
GraphQLSchema, GraphQLUnionType)
17+
from ..utils.undefined import Undefined
1818
from .base import (ExecutionContext, ExecutionResult, ResolveInfo,
19-
collect_fields, default_resolve_fn, get_field_def,
20-
get_operation_root_type, SubscriberExecutionContext)
19+
SubscriberExecutionContext, collect_fields,
20+
default_resolve_fn, get_field_def, get_operation_root_type)
2121
from .executors.sync import SyncExecutor
2222
from .middleware import MiddlewareManager
2323

@@ -147,7 +147,7 @@ def execute_field_callback(results, response_name):
147147
source_value,
148148
field_asts,
149149
None,
150-
path+[response_name]
150+
path + [response_name]
151151
)
152152
if result is Undefined:
153153
return results

graphql/execution/executors/asyncio_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from inspect import isasyncgen
21
from asyncio import ensure_future
3-
from rx import Observable, AnonymousObserver
4-
from rx.core import ObservableBase, Disposable, ObserverBase
2+
from inspect import isasyncgen
53

4+
from rx import AnonymousObserver, Observable
65
from rx.concurrency import current_thread_scheduler
7-
8-
from rx.core import Observer, Observable, Disposable
6+
from rx.core import (Disposable, Observable, ObservableBase, Observer,
7+
ObserverBase)
98
from rx.core.anonymousobserver import AnonymousObserver
109
from rx.core.autodetachobserver import AutoDetachObserver
1110

graphql/execution/tests/test_benchmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from graphql import (GraphQLField, GraphQLInt, GraphQLList, GraphQLObjectType,
55
GraphQLSchema, Source, execute, parse)
6+
67
# from graphql.execution import executor
78

89
# executor.use_experimental_executor = True

graphql/execution/tests/test_dataloader.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import pytest
1+
from graphql import (GraphQLArgument, GraphQLField, GraphQLID, GraphQLNonNull,
2+
GraphQLObjectType, GraphQLSchema, execute, parse)
3+
from graphql.execution.executors.sync import SyncExecutor
4+
from graphql.execution.executors.thread import ThreadExecutor
25
from promise import Promise
36
from promise.dataloader import DataLoader
47

5-
from graphql import GraphQLObjectType, GraphQLField, GraphQLID, GraphQLArgument, GraphQLNonNull, GraphQLSchema, parse, execute
6-
from graphql.execution.executors.sync import SyncExecutor
7-
from graphql.execution.executors.thread import ThreadExecutor
8+
import pytest
89

910

1011
@pytest.mark.parametrize("executor", [

graphql/execution/tests/test_executor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import json
22

3-
from pytest import raises
4-
53
from graphql.error import GraphQLError
64
from graphql.execution import MiddlewareManager, execute
75
from graphql.language.parser import parse
86
from graphql.type import (GraphQLArgument, GraphQLBoolean, GraphQLField,
9-
GraphQLInt, GraphQLList, GraphQLObjectType,
10-
GraphQLSchema, GraphQLString, GraphQLNonNull, GraphQLID)
7+
GraphQLID, GraphQLInt, GraphQLList, GraphQLNonNull,
8+
GraphQLObjectType, GraphQLSchema, GraphQLString)
119
from promise import Promise
1210

11+
from pytest import raises
12+
1313

1414
def test_executes_arbitary_code():
1515
class Data(object):

graphql/execution/tests/test_executor_thread.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ def handle_results(result):
206206
'syncReturnErrorList': ['sync0', None, 'sync2', None]
207207
}
208208
assert sorted(list(map(format_error, result.errors)), key=sort_key) == sorted([
209-
{'locations': [{'line': 4, 'column': 9}], 'path':['syncError'], 'message': 'Error getting syncError'},
210-
{'locations': [{'line': 5, 'column': 9}], 'path':['syncReturnError'], 'message': 'Error getting syncReturnError'},
211-
{'locations': [{'line': 6, 'column': 9}], 'path':['syncReturnErrorList', 1], 'message': 'Error getting syncReturnErrorList1'},
212-
{'locations': [{'line': 6, 'column': 9}], 'path':['syncReturnErrorList', 3], 'message': 'Error getting syncReturnErrorList3'},
213-
{'locations': [{'line': 8, 'column': 9}], 'path':['asyncReject'], 'message': 'Error getting asyncReject'},
214-
{'locations': [{'line': 9, 'column': 9}], 'path':['asyncEmptyReject'], 'message': 'An unknown error occurred.'},
215-
{'locations': [{'line': 10, 'column': 9}], 'path':['asyncReturnError'], 'message': 'Error getting asyncReturnError'}
209+
{'locations': [{'line': 4, 'column': 9}], 'path': ['syncError'], 'message': 'Error getting syncError'},
210+
{'locations': [{'line': 5, 'column': 9}], 'path': ['syncReturnError'], 'message': 'Error getting syncReturnError'},
211+
{'locations': [{'line': 6, 'column': 9}], 'path': ['syncReturnErrorList', 1], 'message': 'Error getting syncReturnErrorList1'},
212+
{'locations': [{'line': 6, 'column': 9}], 'path': ['syncReturnErrorList', 3], 'message': 'Error getting syncReturnErrorList3'},
213+
{'locations': [{'line': 8, 'column': 9}], 'path': ['asyncReject'], 'message': 'Error getting asyncReject'},
214+
{'locations': [{'line': 9, 'column': 9}], 'path': ['asyncEmptyReject'], 'message': 'An unknown error occurred.'},
215+
{'locations': [{'line': 10, 'column': 9}], 'path': ['asyncReturnError'], 'message': 'Error getting asyncReturnError'}
216216
], key=sort_key)
217217

218218
handle_results(execute(schema, ast, Data(), executor=ThreadExecutor()))

graphql/execution/tests/test_located_error.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# coding: utf-8
22

3-
from graphql import GraphQLField
4-
from graphql import GraphQLObjectType
5-
from graphql import GraphQLSchema
6-
from graphql import GraphQLString
7-
from graphql import execute
8-
from graphql import parse
3+
from graphql import (GraphQLField, GraphQLObjectType, GraphQLSchema,
4+
GraphQLString, execute, parse)
95
from graphql.error import GraphQLLocatedError
106

117

graphql/execution/tests/test_nonnull.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -320,27 +320,27 @@ def test_nulls_the_first_nullable_object_after_a_field_throws_in_a_long_chain_of
320320
'errors': [{'locations': [{'column': 19, 'line': 8}],
321321
'path': [
322322
'nest', 'nonNullNest', 'nonNullPromiseNest',
323-
'nonNullNest', 'nonNullPromiseNest', 'nonNullSync'
324-
],
325-
'message': str(non_null_sync_error)},
326-
{'locations': [{'column': 19, 'line': 19}],
327-
'path': [
328-
'promiseNest', 'nonNullNest', 'nonNullPromiseNest',
329-
'nonNullNest', 'nonNullPromiseNest', 'nonNullSync'
330-
],
331-
'message': str(non_null_sync_error)},
332-
{'locations': [{'column': 19, 'line': 30}],
333-
'path': [
334-
'anotherNest', 'nonNullNest', 'nonNullPromiseNest',
335-
'nonNullNest', 'nonNullPromiseNest', 'nonNullPromise'
336-
],
337-
'message': str(non_null_promise_error)},
338-
{'locations': [{'column': 19, 'line': 41}],
339-
'path': [
340-
'anotherPromiseNest', 'nonNullNest', 'nonNullPromiseNest',
341-
'nonNullNest', 'nonNullPromiseNest', 'nonNullPromise'
342-
],
343-
'message': str(non_null_promise_error)}]
323+
'nonNullNest', 'nonNullPromiseNest', 'nonNullSync'
324+
],
325+
'message': str(non_null_sync_error)},
326+
{'locations': [{'column': 19, 'line': 19}],
327+
'path': [
328+
'promiseNest', 'nonNullNest', 'nonNullPromiseNest',
329+
'nonNullNest', 'nonNullPromiseNest', 'nonNullSync'
330+
],
331+
'message': str(non_null_sync_error)},
332+
{'locations': [{'column': 19, 'line': 30}],
333+
'path': [
334+
'anotherNest', 'nonNullNest', 'nonNullPromiseNest',
335+
'nonNullNest', 'nonNullPromiseNest', 'nonNullPromise'
336+
],
337+
'message': str(non_null_promise_error)},
338+
{'locations': [{'column': 19, 'line': 41}],
339+
'path': [
340+
'anotherPromiseNest', 'nonNullNest', 'nonNullPromiseNest',
341+
'nonNullNest', 'nonNullPromiseNest', 'nonNullPromise'
342+
],
343+
'message': str(non_null_promise_error)}]
344344
})
345345

346346

graphql/execution/tests/test_subscribe.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from collections import OrderedDict, namedtuple
2+
3+
from graphql import (GraphQLBoolean, GraphQLField, GraphQLInt, GraphQLList,
4+
GraphQLObjectType, GraphQLSchema, GraphQLString, graphql,
5+
parse, subscribe)
26
from rx import Observable, Observer
37
from rx.subjects import Subject
4-
from graphql import parse, GraphQLObjectType, GraphQLString, GraphQLBoolean, GraphQLInt, GraphQLField, GraphQLList, GraphQLSchema, graphql, subscribe
58

69
Email = namedtuple('Email', 'from_,subject,message,unread')
710

graphql/execution/tests/test_variables.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import json
22
from collections import OrderedDict
33

4-
from pytest import raises
5-
64
from graphql.error import GraphQLError, format_error
75
from graphql.execution import execute
86
from graphql.language.parser import parse
9-
from graphql.type import (GraphQLArgument, GraphQLField, GraphQLBoolean,
7+
from graphql.type import (GraphQLArgument, GraphQLBoolean, GraphQLField,
108
GraphQLInputObjectField, GraphQLInputObjectType,
119
GraphQLList, GraphQLNonNull, GraphQLObjectType,
1210
GraphQLScalarType, GraphQLSchema, GraphQLString)
1311

12+
from pytest import raises
13+
1414
TestComplexScalar = GraphQLScalarType(
1515
name='ComplexScalar',
1616
serialize=lambda v: 'SerializedValue' if v == 'DeserializedValue' else None,

graphql/graphql.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from .execution import ExecutionResult
1+
from promise import promisify
2+
23
from .backend import get_default_backend
4+
from .execution import ExecutionResult
35

4-
from promise import promisify
56

67
# This is the primary entry point function for fulfilling GraphQL operations
78
# by parsing, validating, and executing a GraphQL document along side a

graphql/language/tests/test_lexer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pytest import raises
2-
31
from graphql.error import GraphQLSyntaxError
42
from graphql.language.lexer import Lexer, Token, TokenKind
53
from graphql.language.source import Source
64

5+
from pytest import raises
6+
77

88
def lex_one(s):
99
return Lexer(Source(s)).next_token()

0 commit comments

Comments
 (0)