Skip to content

Commit 421db50

Browse files
committed
Fix Flake8 + Python3
1 parent 2ae43d5 commit 421db50

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

graphql/core/execution/executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def complete_value(self, ctx, return_type, field_asts, info, result):
253253
if isinstance(return_type, GraphQLList):
254254
assert isinstance(result, collections.Iterable), \
255255
('User Error: expected iterable, but did not find one' +
256-
'for field {}.{}').format(info.parent_type, info.field_name)
256+
'for field {}.{}').format(info.parent_type, info.field_name)
257257

258258
item_type = return_type.of_type
259259
completed_results = []

graphql/core/validation/rules/fields_on_correct_type.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
from collections import Counter
1+
from collections import Counter, OrderedDict
2+
try:
3+
# Python 2
4+
from itertools import izip
5+
except ImportError:
6+
# Python 3
7+
izip = zip
28

39
from ...error import GraphQLError
4-
from ...type.definition import is_abstract_type, GraphQLObjectType
10+
from ...type.definition import GraphQLObjectType, is_abstract_type
511
from .base import ValidationRule
612

713

14+
class OrderedCounter(Counter, OrderedDict):
15+
pass
16+
17+
818
class FieldsOnCorrectType(ValidationRule):
919

1020
def enter_Field(self, node, key, parent, path, ancestors):
@@ -49,13 +59,14 @@ def get_sibling_interfaces_including_field(type, field_name):
4959
interface.'''
5060

5161
implementing_objects = filter(lambda t: isinstance(t, GraphQLObjectType), type.get_possible_types())
52-
suggested_interfaces = Counter()
62+
suggested_interfaces = OrderedCounter()
5363
for t in implementing_objects:
5464
for i in t.get_interfaces():
5565
if field_name not in i.get_fields():
56-
break
66+
continue
5767
suggested_interfaces[i.name] += 1
5868
most_common = suggested_interfaces.most_common()
5969
if not most_common:
6070
return []
61-
return list(zip(*most_common)[0])
71+
# Get first element of each list (excluding the counter int)
72+
return list(next(izip(*most_common)))

0 commit comments

Comments
 (0)