Skip to content

Commit a2ab008

Browse files
committed
Fixed lint errors
1 parent 7073208 commit a2ab008

22 files changed

+167
-65
lines changed

bin/autolinter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

33
autoflake ./ -r --remove-unused-variables --remove-all-unused-imports --in-place
4-
autopep8 ./ -r --in-place
4+
autopep8 ./ -r --in-place --experimental --aggressive --max-line-length 120
55
isort -rc .

graphene/__init__.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,30 @@
4040
resolve_only_args
4141
)
4242

43-
__all__ = ['Enum', 'Argument', 'String', 'Int', 'Boolean', 'Float', 'ID', 'List', 'NonNull', 'signals', 'Schema',
44-
'BaseType', 'LazyType', 'ObjectType', 'Interface', 'Mutation', 'Field', 'InputField', 'StringField',
45-
'IntField', 'BooleanField', 'IDField', 'ListField', 'NonNullField',
46-
'FloatField', 'resolve_only_args']
43+
__all__ = [
44+
'Enum',
45+
'Argument',
46+
'String',
47+
'Int',
48+
'Boolean',
49+
'Float',
50+
'ID',
51+
'List',
52+
'NonNull',
53+
'signals',
54+
'Schema',
55+
'BaseType',
56+
'LazyType',
57+
'ObjectType',
58+
'Interface',
59+
'Mutation',
60+
'Field',
61+
'InputField',
62+
'StringField',
63+
'IntField',
64+
'BooleanField',
65+
'IDField',
66+
'ListField',
67+
'NonNullField',
68+
'FloatField',
69+
'resolve_only_args']

graphene/contrib/django/converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class UUIDField(object):
1616
@singledispatch
1717
def convert_django_field(field):
1818
raise Exception(
19-
"Don't know how to convert the Django field %s (%s)" % (field, field.__class__))
19+
"Don't know how to convert the Django field %s (%s)" %
20+
(field, field.__class__))
2021

2122

2223
@convert_django_field.register(models.DateField)

graphene/contrib/django/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def contribute_to_class(self, cls, name):
3232
return
3333
if not self.model:
3434
raise Exception(
35-
'Django ObjectType %s must have a model in the Meta class attr' % cls)
35+
'Django ObjectType %s must have a model in the Meta class attr' %
36+
cls)
3637
elif not inspect.isclass(self.model) or not issubclass(self.model, models.Model):
3738
raise Exception('Provided model in %s is not a Django model' % cls)

graphene/contrib/django/tests/test_query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class Query(graphene.ObjectType):
8787
article = graphene.Field(ArticleNode)
8888

8989
def resolve_reporter(self, *args, **kwargs):
90-
return ReporterNode(Reporter(id=1, first_name='ABA', last_name='X'))
90+
return ReporterNode(
91+
Reporter(id=1, first_name='ABA', last_name='X'))
9192

9293
query = '''
9394
query ReporterQuery {

graphene/contrib/django/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ def __getattr__(self, attr):
4646
return getattr(self.instance, attr)
4747

4848

49-
class DjangoObjectType(six.with_metaclass(DjangoObjectTypeMeta, InstanceObjectType)):
49+
class DjangoObjectType(six.with_metaclass(
50+
DjangoObjectTypeMeta, InstanceObjectType)):
5051
pass
5152

5253

53-
class DjangoInterface(six.with_metaclass(DjangoObjectTypeMeta, InstanceObjectType)):
54+
class DjangoInterface(six.with_metaclass(
55+
DjangoObjectTypeMeta, InstanceObjectType)):
5456
pass
5557

5658

graphene/contrib/django/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ def response_errors(self, *errors):
2828
errors = [{
2929
"message": str(e)
3030
} for e in errors]
31-
return HttpResponse(json.dumps({'errors': errors}), content_type='application/json')
31+
return HttpResponse(
32+
json.dumps({'errors': errors}),
33+
content_type='application/json')
3234

3335
def execute_query(self, request, query, *args, **kwargs):
3436
if not query:
35-
return self.response_errors(Exception("Must provide query string."))
37+
return self.response_errors(
38+
Exception("Must provide query string."))
3639
else:
3740
try:
3841
result = self.schema.execute(query, *args, **kwargs)
@@ -59,7 +62,8 @@ def post(self, request, *args, **kwargs):
5962
received_json_data = json.loads(request.body.decode())
6063
query = received_json_data.get('query')
6164
except ValueError:
62-
return self.response_errors(ValueError("Malformed json body in the post data"))
65+
return self.response_errors(ValueError(
66+
"Malformed json body in the post data"))
6367
else:
6468
query = request.POST.get('query') or request.GET.get('query')
6569
return self.execute_query(request, query or '')

graphene/core/options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def contribute_to_class(self, cls, name):
5252
# Any leftover attributes must be invalid.
5353
if meta_attrs != {}:
5454
raise TypeError(
55-
"'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()))
55+
"'class Meta' got invalid attribute(s): %s" %
56+
','.join(
57+
meta_attrs.keys()))
5658
else:
5759
self.proxy = False
5860

graphene/core/schema.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def __init__(self, schema, *args, **kwargs):
2121
class Schema(object):
2222
_executor = None
2323

24-
def __init__(self, query=None, mutation=None, name='Schema', executor=None):
24+
def __init__(self, query=None, mutation=None,
25+
name='Schema', executor=None):
2526
self._types_names = {}
2627
self._types = {}
2728
self.mutation = mutation
@@ -36,7 +37,9 @@ def __repr__(self):
3637
def T(self, object_type):
3738
if not object_type:
3839
return
39-
if inspect.isclass(object_type) and issubclass(object_type, BaseType) or isinstance(object_type, BaseType):
40+
if inspect.isclass(object_type) and issubclass(
41+
object_type, BaseType) or isinstance(
42+
object_type, BaseType):
4043
if object_type not in self._types:
4144
internal_type = object_type.internal_type(self)
4245
self._types[object_type] = internal_type
@@ -63,7 +66,9 @@ def executor(self, value):
6366
def schema(self):
6467
if not self.query:
6568
raise Exception('You have to define a base query type')
66-
return GraphQLSchema(self, query=self.T(self.query), mutation=self.T(self.mutation))
69+
return GraphQLSchema(
70+
self, query=self.T(self.query),
71+
mutation=self.T(self.mutation))
6772

6873
def register(self, object_type):
6974
type_name = object_type._meta.type_name
@@ -78,7 +83,8 @@ def objecttype(self, type):
7883
name = getattr(type, 'name', None)
7984
if name:
8085
objecttype = self._types_names.get(name, None)
81-
if objecttype and inspect.isclass(objecttype) and issubclass(objecttype, BaseObjectType):
86+
if objecttype and inspect.isclass(
87+
objecttype) and issubclass(objecttype, BaseObjectType):
8288
return objecttype
8389

8490
def setup(self):
@@ -95,7 +101,8 @@ def get_type(self, type_name):
95101
def types(self):
96102
return self._types_names
97103

98-
def execute(self, request='', root=None, vars=None, operation_name=None, **kwargs):
104+
def execute(self, request='', root=None, vars=None,
105+
operation_name=None, **kwargs):
99106
root = root or object()
100107
return self.executor.execute(
101108
self.schema,

graphene/core/tests/test_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def test_query_schema_execute():
9292
def test_schema_get_type_map():
9393
assert_equal_lists(
9494
schema.schema.get_type_map().keys(),
95-
['__Field', 'String', 'Pet', 'Character', '__InputValue', '__Directive',
96-
'__TypeKind', '__Schema', '__Type', 'Human', '__EnumValue', 'Boolean']
97-
)
95+
['__Field', 'String', 'Pet', 'Character', '__InputValue',
96+
'__Directive', '__TypeKind', '__Schema', '__Type', 'Human',
97+
'__EnumValue', 'Boolean'])
9898

9999

100100
def test_schema_no_query():

0 commit comments

Comments
 (0)