Skip to content

Commit 4b7078a

Browse files
committed
Fixed Pep8 issues
1 parent ff51da2 commit 4b7078a

20 files changed

+754
-676
lines changed

graphql_relay/__init__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
from .connection.connection import (
2-
connectionArgs,
3-
connectionDefinitions
2+
connectionArgs,
3+
connectionDefinitions
44
)
55
from .connection.arrayconnection import (
6-
connectionFromArray,
7-
connectionFromPromisedArray,
8-
cursorForObjectInConnection
6+
connectionFromArray,
7+
connectionFromPromisedArray,
8+
cursorForObjectInConnection
99
)
1010
from .node.node import (
11-
nodeDefinitions,
12-
fromGlobalId,
13-
toGlobalId,
14-
globalIdField,
11+
nodeDefinitions,
12+
fromGlobalId,
13+
toGlobalId,
14+
globalIdField,
1515
)
1616
from .mutation.mutation import (
17-
mutationWithClientMutationId
17+
mutationWithClientMutationId
1818
)
1919

2020
__all__ = [
21-
# Helpers for creating connection types in the schema
22-
'connectionArgs', 'connectionDefinitions',
23-
# Helpers for creating connections from arrays
24-
'connectionFromArray', 'connectionFromPromisedArray', 'cursorForObjectInConnection',
25-
# Helper for creating node definitions
26-
'nodeDefinitions',
27-
# Utilities for creating global IDs in systems that don't have them
28-
'fromGlobalId', 'toGlobalId', 'globalIdField',
29-
# Helper for creating mutations with client mutation IDs
30-
'mutationWithClientMutationId'
21+
# Helpers for creating connection types in the schema
22+
'connectionArgs', 'connectionDefinitions',
23+
# Helpers for creating connections from arrays
24+
'connectionFromArray', 'connectionFromPromisedArray', 'cursorForObjectInConnection',
25+
# Helper for creating node definitions
26+
'nodeDefinitions',
27+
# Utilities for creating global IDs in systems that don't have them
28+
'fromGlobalId', 'toGlobalId', 'globalIdField',
29+
# Helper for creating mutations with client mutation IDs
30+
'mutationWithClientMutationId'
3131
]

graphql_relay/connection/arrayconnection.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def connectionFromArray(data, args={}, **kwargs):
2020
# Slice with cursors
2121
begin = max(getOffset(after, -1), -1) + 1
2222
end = min(getOffset(before, count + 1), count)
23-
if begin >= count or begin>=end:
23+
if begin >= count or begin >= end:
2424
return emptyConnection()
2525

2626
# Save the pre-slice cursors
@@ -33,7 +33,7 @@ def connectionFromArray(data, args={}, **kwargs):
3333
if last != None:
3434
begin = max(end-last, begin)
3535

36-
if begin >= count or begin>=end:
36+
if begin >= count or begin >= end:
3737
return emptyConnection()
3838

3939
sliced_data = data[begin:end]
@@ -50,8 +50,8 @@ def connectionFromArray(data, args={}, **kwargs):
5050
PageInfo(
5151
startCursor=firstEdge.cursor,
5252
endCursor=lastEdge.cursor,
53-
hasPreviousPage= (firstEdge.cursor != firstPresliceCursor),
54-
hasNextPage= (lastEdge.cursor != lastPresliceCursor)
53+
hasPreviousPage=(firstEdge.cursor != firstPresliceCursor),
54+
hasNextPage=(lastEdge.cursor != lastPresliceCursor)
5555
)
5656
)
5757

@@ -100,6 +100,7 @@ def cursorToOffset(cursor):
100100
except:
101101
return None
102102

103+
103104
def cursorForObjectInConnection(data, _object):
104105
'''
105106
Return the cursor associated with an object in an array.

graphql_relay/connection/connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212

1313
class ConnectionConfig(object):
14+
1415
'''
1516
Returns a GraphQLFieldConfigArgumentMap appropriate to include
1617
on a field whose return type is a connection type.
1718
'''
19+
1820
def __init__(self, name, nodeType, edgeFields=None, connectionFields=None):
1921
self.name = name
2022
self.nodeType = nodeType
@@ -23,6 +25,7 @@ def __init__(self, name, nodeType, edgeFields=None, connectionFields=None):
2325

2426

2527
class GraphQLConnection(object):
28+
2629
def __init__(self, edgeType, connectionType):
2730
self.edgeType = edgeType
2831
self.connectionType = connectionType
@@ -88,7 +91,7 @@ def connectionDefinitions(*args, **kwargs):
8891
pageInfoType = GraphQLObjectType(
8992
'PageInfo',
9093
description='Information about pagination in a connection.',
91-
fields=lambda:{
94+
fields=lambda: {
9295
'hasNextPage': GraphQLField(
9396
GraphQLNonNull(GraphQLBoolean),
9497
description='When paginating forwards, are there more items?',

graphql_relay/connection/connectiontypes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class Connection(object):
2+
23
def __init__(self, edges, pageInfo):
34
self.edges = edges
45
self.pageInfo = pageInfo
@@ -9,7 +10,9 @@ def to_dict(self):
910
'pageInfo': self.pageInfo.to_dict(),
1011
}
1112

13+
1214
class PageInfo(object):
15+
1316
def __init__(self, startCursor="", endCursor="", hasPreviousPage=False, hasNextPage=False):
1417
self.startCursor = startCursor
1518
self.endCursor = endCursor
@@ -24,7 +27,9 @@ def to_dict(self):
2427
'hasNextPage': self.hasNextPage,
2528
}
2629

30+
2731
class Edge(object):
32+
2833
def __init__(self, node, cursor):
2934
self.node = node
3035
self.cursor = cursor

graphql_relay/mutation/mutation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
)
1010
from graphql.core.error import GraphQLError
1111

12+
1213
def mutationWithClientMutationId(name, inputFields, outputFields, mutateAndGetPayload):
1314
augmentedInputFields = dict(inputFields,
14-
clientMutationId=GraphQLInputObjectField(GraphQLNonNull(GraphQLString))
15-
)
15+
clientMutationId=GraphQLInputObjectField(
16+
GraphQLNonNull(GraphQLString))
17+
)
1618
augmentedOutputFields = dict(outputFields,
17-
clientMutationId=GraphQLField(GraphQLNonNull(GraphQLString))
18-
)
19+
clientMutationId=GraphQLField(
20+
GraphQLNonNull(GraphQLString))
21+
)
1922
inputType = GraphQLInputObjectType(
2023
name+'Input',
2124
fields=augmentedInputFields,
@@ -34,7 +37,8 @@ def resolver(__, args, info, *_):
3437
try:
3538
payload.clientMutationId = input['clientMutationId']
3639
except:
37-
raise GraphQLError('Cannot set clientMutationId in the payload object %s'%repr(payload))
40+
raise GraphQLError(
41+
'Cannot set clientMutationId in the payload object %s' % repr(payload))
3842
return payload
3943

4044
return GraphQLField(

graphql_relay/node/node.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
class GraphQLNode(object):
14+
1415
def __init__(self, nodeInterface, nodeField):
1516
self.nodeInterface = nodeInterface
1617
self.nodeField = nodeField
@@ -29,30 +30,31 @@ def nodeDefinitions(idFetcher, typeResolver=None):
2930
'''
3031
nodeInterface = GraphQLInterfaceType(
3132
'Node',
32-
description= 'An object with an ID',
33-
fields= lambda:{
33+
description='An object with an ID',
34+
fields=lambda: {
3435
'id': GraphQLField(
3536
GraphQLNonNull(GraphQLID),
3637
description='The id of the object.',
3738
),
3839
},
39-
resolve_type= typeResolver
40+
resolve_type=typeResolver
4041
)
4142
nodeField = GraphQLField(
4243
nodeInterface,
43-
description= 'Fetches an object given its ID',
44-
args= {
44+
description='Fetches an object given its ID',
45+
args={
4546
'id': GraphQLArgument(
4647
GraphQLNonNull(GraphQLID),
4748
description='The ID of an object'
4849
)
4950
},
50-
resolver= lambda obj, args, info: idFetcher(args.get('id'), info)
51+
resolver=lambda obj, args, info: idFetcher(args.get('id'), info)
5152
)
5253
return GraphQLNode(nodeInterface, nodeField)
5354

5455

5556
class ResolvedGlobalId(object):
57+
5658
def __init__(self, type, id):
5759
self.type = type
5860
self.id = id
@@ -65,6 +67,7 @@ def toGlobalId(type, id):
6567
'''
6668
return base64(':'.join([type, str(id)]))
6769

70+
6871
def fromGlobalId(globalId):
6972
'''
7073
Takes the "global ID" created by toGlobalID, and retuns the type name and ID
@@ -84,6 +87,7 @@ def globalIdField(typeName, idFetcher=None):
8487
'''
8588
return GraphQLField(
8689
GraphQLNonNull(GraphQLID),
87-
description= 'The ID of an object',
88-
resolver= lambda obj, *_: toGlobalId(typeName, idFetcher(obj) if idFetcher else obj.id)
90+
description='The ID of an object',
91+
resolver=lambda obj, *
92+
_: toGlobalId(typeName, idFetcher(obj) if idFetcher else obj.id)
8993
)

graphql_relay/node/plural.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
)
88
# GraphQLInputObjectType
99

10+
1011
def pluralIdentifyingRootField(argName, inputType, outputType, resolveSingleInput, description=None):
1112
inputArgs = {}
1213
inputArgs[argName] = GraphQLArgument(
@@ -16,6 +17,7 @@ def pluralIdentifyingRootField(argName, inputType, outputType, resolveSingleInpu
1617
)
1718
)
1819
)
20+
1921
def resolver(obj, args, *_):
2022
inputs = args[argName]
2123
return map(resolveSingleInput, inputs)
@@ -24,5 +26,5 @@ def resolver(obj, args, *_):
2426
GraphQLList(outputType),
2527
description=description,
2628
args=inputArgs,
27-
resolver=resolver
29+
resolver=resolver
2830
)

graphql_relay/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
unbase64 = _unbase64
77
except NameError:
88
def base64(s):
9-
return _base64(bytes(s, 'utf-8')).decode('utf-8')
9+
return _base64(bytes(s, 'utf-8')).decode('utf-8')
10+
1011
def unbase64(s):
11-
return _unbase64(s).decode('utf-8')
12+
return _unbase64(s).decode('utf-8')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def finalize_options(self):
1717
self.test_suite = True
1818

1919
def run_tests(self):
20-
#import here, cause outside the eggs aren't loaded
20+
# import here, cause outside the eggs aren't loaded
2121
import pytest
2222
errno = pytest.main(self.pytest_args)
2323
sys.exit(errno)

0 commit comments

Comments
 (0)