Skip to content

Commit 1b3e7f3

Browse files
dan98765jkimbo
authored andcommitted
Add flake8 pre-commit hook and manually edit files to pass flake8 validation (#746)
Add flake8 pre-commit hook and manually edit files to pass flake8 validation
1 parent 8bf937d commit 1b3e7f3

16 files changed

+38
-33
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: git://github.com/pre-commit/pre-commit-hooks
3-
rev: v1.2.3
3+
rev: v1.3.0
44
hooks:
55
- id: autopep8-wrapper
66
args:
@@ -16,6 +16,7 @@ repos:
1616
- id: pretty-format-json
1717
args:
1818
- --autofix
19+
- id: flake8
1920
- repo: https://github.com/asottile/seed-isort-config
2021
rev: v1.0.0
2122
hooks:

graphene/relay/tests/test_connection_query.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def resolve_connection_letters(self, info, **args):
5656

5757
letters = OrderedDict()
5858
for i, letter in enumerate(letter_chars):
59-
l = Letter(id=i, letter=letter)
60-
letters[letter] = l
59+
letters[letter] = Letter(id=i, letter=letter)
6160

6261

6362
def edges(selected_letters):
@@ -74,8 +73,8 @@ def edges(selected_letters):
7473

7574

7675
def cursor_for(ltr):
77-
l = letters[ltr]
78-
return base64('arrayconnection:%s' % l.id)
76+
letter = letters[ltr]
77+
return base64('arrayconnection:%s' % letter.id)
7978

8079

8180
def execute(args=''):

graphene/tests/issues/test_313.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# https://github.com/graphql-python/graphene/issues/313
22

33
import graphene
4-
from graphene import resolve_only_args
54

65

76
class Query(graphene.ObjectType):

graphene/tests/issues/test_356.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ class Meta:
2121

2222

2323
def test_issue():
24-
with pytest.raises(Exception) as exc_info:
25-
class Query(graphene.ObjectType):
26-
things = relay.ConnectionField(MyUnion)
24+
class Query(graphene.ObjectType):
25+
things = relay.ConnectionField(MyUnion)
2726

28-
schema = graphene.Schema(query=Query)
27+
with pytest.raises(Exception) as exc_info:
28+
graphene.Schema(query=Query)
2929

30-
assert str(exc_info.value) == 'IterableConnectionField type have to be a subclass of Connection. Received "MyUnion".'
30+
assert str(exc_info.value) == (
31+
'IterableConnectionField type have to be a subclass of Connection. '
32+
'Received "MyUnion".'
33+
)

graphene/tests/issues/test_425.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# Adapted for Graphene 2.0
33

44
from graphene.types.enum import Enum, EnumOptions
5-
from graphene.types.inputobjecttype import (InputObjectType,
6-
InputObjectTypeOptions)
5+
from graphene.types.inputobjecttype import InputObjectType
76
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
87

98

graphene/types/tests/test_abstracttype.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
from .. import abstracttype
42
from ..abstracttype import AbstractType
53
from ..field import Field

graphene/types/tests/test_argument.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def test_to_arguments_raises_if_field():
5151
with pytest.raises(ValueError) as exc_info:
5252
to_arguments(args)
5353

54-
assert str(exc_info.value) == 'Expected arg_string to be Argument, but received Field. Try using Argument(String).'
54+
assert str(exc_info.value) == (
55+
'Expected arg_string to be Argument, but received Field. Try using '
56+
'Argument(String).'
57+
)
5558

5659

5760
def test_to_arguments_raises_if_inputfield():
@@ -62,7 +65,10 @@ def test_to_arguments_raises_if_inputfield():
6265
with pytest.raises(ValueError) as exc_info:
6366
to_arguments(args)
6467

65-
assert str(exc_info.value) == 'Expected arg_string to be Argument, but received InputField. Try using Argument(String).'
68+
assert str(exc_info.value) == (
69+
'Expected arg_string to be Argument, but received InputField. Try '
70+
'using Argument(String).'
71+
)
6672

6773

6874
def test_argument_with_lazy_type():

graphene/types/tests/test_base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
from ..base import BaseOptions, BaseType
42

53

graphene/types/tests/test_datetime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_bad_datetime_query():
6262

6363
assert len(result.errors) == 1
6464
assert isinstance(result.errors[0], GraphQLError)
65-
assert result.data == None
65+
assert result.data is None
6666

6767

6868
def test_bad_date_query():
@@ -72,7 +72,7 @@ def test_bad_date_query():
7272

7373
assert len(result.errors) == 1
7474
assert isinstance(result.errors[0], GraphQLError)
75-
assert result.data == None
75+
assert result.data is None
7676

7777

7878
def test_bad_time_query():
@@ -82,7 +82,7 @@ def test_bad_time_query():
8282

8383
assert len(result.errors) == 1
8484
assert isinstance(result.errors[0], GraphQLError)
85-
assert result.data == None
85+
assert result.data is None
8686

8787

8888
def test_datetime_query_variable():

graphene/types/tests/test_definition.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,14 @@ def test_stringifies_simple_types():
288288
# ]
289289
# for x in bad_union_types:
290290
# with raises(Exception) as excinfo:
291-
# GraphQLSchema(GraphQLObjectType('Root', fields={'union': GraphQLField(GraphQLUnionType('BadUnion', [x]))}))
291+
# GraphQLSchema(
292+
# GraphQLObjectType(
293+
# 'Root',
294+
# fields={
295+
# 'union': GraphQLField(GraphQLUnionType('BadUnion', [x]))
296+
# }
297+
# )
298+
# )
292299

293300
# assert 'BadUnion may only contain Object types, it cannot contain: ' + str(x) + '.' \
294301
# == str(excinfo.value)

0 commit comments

Comments
 (0)