Skip to content

Commit 4aecd32

Browse files
authored
Merge pull request #178 from dan98765/daniellg_add_precommit
Add pre-commit tool to repository, and run on all files.
2 parents aae1d69 + ffa86a8 commit 4aecd32

22 files changed

+67
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ htmlcov/
4646
nosetests.xml
4747
coverage.xml
4848
*,cover
49+
.pytest_cache/
4950

5051
# Translations
5152
*.mo

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- repo: git://github.com/pre-commit/pre-commit-hooks
2+
sha: v0.8.0
3+
hooks:
4+
- id: autopep8-wrapper
5+
args:
6+
- -i
7+
- --ignore=E128,E309,E501
8+
exclude: ^docs/.*$
9+
- id: check-json
10+
- id: check-yaml
11+
- id: debug-statements
12+
- id: end-of-file-fixer
13+
exclude: ^docs/.*$
14+
- id: trailing-whitespace
15+
- id: pretty-format-json
16+
args:
17+
- --autofix
18+
- --indent=4

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ For questions, ask [Stack Overflow](http://stackoverflow.com/questions/tagged/gr
1717

1818
## Getting Started
1919

20-
An overview of the GraphQL language is available in the
20+
An overview of the GraphQL language is available in the
2121
[README](https://github.com/facebook/graphql/blob/master/README.md) for the
22-
[Specification for GraphQL](https://github.com/facebook/graphql).
22+
[Specification for GraphQL](https://github.com/facebook/graphql).
2323

2424
The overview describes a simple set of GraphQL examples that exist as [tests](https://github.com/graphql-python/graphql-core/tree/master/tests/)
2525
in this repository. A good way to get started is to walk through that README and the corresponding tests
26-
in parallel.
26+
in parallel.
2727

2828
### Using graphql-core
2929

graphql/error/tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def resolver(context, *_):
3939
formatted_tb = [row[2:] for row in extracted]
4040
if formatted_tb[2][0] == 'reraise':
4141
formatted_tb[2:] = formatted_tb[3:]
42-
42+
4343
assert formatted_tb == [
4444
('test_reraise', 'result.errors[0].reraise()'),
4545
('reraise', 'six.reraise(type(self), self, self.stack)'),

graphql/execution/executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def resolve_field(exe_context, parent_type, source, field_asts, parent_info):
256256
operation=exe_context.operation,
257257
variable_values=exe_context.variable_values,
258258
context=context,
259-
path=parent_info.path+[field_name] if parent_info else [field_name]
259+
path=parent_info.path + [field_name] if parent_info else [field_name]
260260
)
261261

262262
executor = exe_context.executor

graphql/execution/tests/test_abstract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, name):
2525
self.name = name
2626

2727

28-
is_type_of = lambda type: lambda obj, info: isinstance(obj, type)
28+
def is_type_of(type): return lambda obj, info: isinstance(obj, type)
2929

3030

3131
def make_type_resolver(types):

graphql/execution/tests/test_dataloader.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def test_batches_correctly(executor):
2828

2929
schema = GraphQLSchema(query=Query)
3030

31-
3231
doc = '''
3332
{
3433
business1: getBusiness(id: "1") {
@@ -41,9 +40,8 @@ def test_batches_correctly(executor):
4140
'''
4241
doc_ast = parse(doc)
4342

44-
4543
load_calls = []
46-
44+
4745
class BusinessDataLoader(DataLoader):
4846
def batch_load_fn(self, keys):
4947
load_calls.append(keys)
@@ -52,7 +50,6 @@ def batch_load_fn(self, keys):
5250
class Context(object):
5351
business_data_loader = BusinessDataLoader()
5452

55-
5653
result = execute(schema, doc_ast, None, context_value=Context(), executor=executor)
5754
assert not result.errors
5855
assert result.data == {
@@ -63,7 +60,7 @@ class Context(object):
6360
'id': '2'
6461
},
6562
}
66-
assert load_calls == [['1','2']]
63+
assert load_calls == [['1', '2']]
6764

6865

6966
@pytest.mark.parametrize("executor", [
@@ -78,8 +75,11 @@ def test_batches_multiple_together(executor):
7875

7976
Business = GraphQLObjectType('Business', lambda: {
8077
'id': GraphQLField(GraphQLID, resolver=lambda root, info, **args: root),
81-
'location': GraphQLField(Location,
82-
resolver=lambda root, info, **args: info.context.location_data_loader.load('location-{}'.format(root))
78+
'location': GraphQLField(
79+
Location,
80+
resolver=lambda root, info, **args: info.context.location_data_loader.load(
81+
'location-{}'.format(root)
82+
)
8383
),
8484
})
8585

@@ -94,7 +94,6 @@ def test_batches_multiple_together(executor):
9494

9595
schema = GraphQLSchema(query=Query)
9696

97-
9897
doc = '''
9998
{
10099
business1: getBusiness(id: "1") {
@@ -113,16 +112,15 @@ def test_batches_multiple_together(executor):
113112
'''
114113
doc_ast = parse(doc)
115114

116-
117115
business_load_calls = []
118-
116+
119117
class BusinessDataLoader(DataLoader):
120118
def batch_load_fn(self, keys):
121119
business_load_calls.append(keys)
122120
return Promise.resolve(keys)
123121

124122
location_load_calls = []
125-
123+
126124
class LocationDataLoader(DataLoader):
127125
def batch_load_fn(self, keys):
128126
location_load_calls.append(keys)
@@ -132,7 +130,6 @@ class Context(object):
132130
business_data_loader = BusinessDataLoader()
133131
location_data_loader = LocationDataLoader()
134132

135-
136133
result = execute(schema, doc_ast, None, context_value=Context(), executor=executor)
137134
assert not result.errors
138135
assert result.data == {
@@ -149,5 +146,5 @@ class Context(object):
149146
}
150147
},
151148
}
152-
assert business_load_calls == [['1','2']]
153-
assert location_load_calls == [['location-1','location-2']]
149+
assert business_load_calls == [['1', '2']]
150+
assert location_load_calls == [['location-1', 'location-2']]

graphql/execution/tests/test_executor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,4 +812,3 @@ def resolve(self, _next, root, info, *args, **kwargs):
812812
['feed', 1, 'author', 'id'],
813813
['feed', 1, 'author', 'name']
814814
]
815-

graphql/execution/tests/test_located_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def resolver(context, *_):
2020
})
2121

2222
result = execute(GraphQLSchema(Type), ast)
23-
assert isinstance(result.errors[0], GraphQLLocatedError)
23+
assert isinstance(result.errors[0], GraphQLLocatedError)

graphql/execution/tests/test_resolve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
GraphQLObjectType, GraphQLSchema, GraphQLString)
99
from promise import Promise
1010

11+
1112
class CustomPromise(Promise):
1213
@classmethod
1314
def fulfilled(cls, x):
@@ -150,7 +151,6 @@ def test_maps_argument_out_names_well_with_input():
150151
def resolver(source, info, **args):
151152
return json.dumps([source, args], separators=(',', ':'))
152153

153-
154154
TestInputObject = GraphQLInputObjectType('TestInputObject', lambda: OrderedDict([
155155
('inputOne', GraphQLInputObjectField(GraphQLString, out_name="input_one")),
156156
('inputRecursive', GraphQLInputObjectField(TestInputObject, out_name="input_recursive")),

0 commit comments

Comments
 (0)