Skip to content

Commit b668e47

Browse files
committed
Reformat with latest black version (20.8b1)
1 parent a455edf commit b668e47

20 files changed

+142
-57
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pytest-benchmark = "^3.2"
3838
pytest-cov = "^2.10"
3939
pytest-describe = "^1.0"
4040
pytest-timeout = "^1.4"
41-
black = "19.10b0"
41+
black = "20.8b1"
4242
flake8 = "^3.8"
4343
mypy = "0.782"
4444
codecov = "^2"

src/graphql/execution/execute.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ async def await_and_set_result(
392392
elif is_awaitable(result):
393393
# noinspection PyShadowingNames
394394
async def set_result(
395-
results: Dict[str, Any], response_name: str, result: Awaitable,
395+
results: Dict[str, Any],
396+
response_name: str,
397+
result: Awaitable,
396398
) -> Dict[str, Any]:
397399
results[response_name] = await result
398400
return results

src/graphql/type/schema.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ def is_possible_type(
317317
return self.is_sub_type(abstract_type, possible_type)
318318

319319
def is_sub_type(
320-
self, abstract_type: GraphQLAbstractType, maybe_sub_type: GraphQLNamedType,
320+
self,
321+
abstract_type: GraphQLAbstractType,
322+
maybe_sub_type: GraphQLNamedType,
321323
) -> bool:
322324
"""Check whether a type is a subtype of a given abstract type."""
323325
types = self._sub_type_map.get(abstract_type.name)

src/graphql/utilities/type_from_ast.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def type_from_ast(schema: GraphQLSchema, type_node: TypeNode) -> Optional[GraphQ
4040
...
4141

4242

43-
def type_from_ast(schema: GraphQLSchema, type_node: TypeNode,) -> Optional[GraphQLType]:
43+
def type_from_ast(
44+
schema: GraphQLSchema,
45+
type_node: TypeNode,
46+
) -> Optional[GraphQLType]:
4447
"""Get the GraphQL type definition from an AST node.
4548
4649
Given a Schema and an AST node describing a type, return a GraphQLType definition

src/graphql/validation/rules/executable_definitions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def enter_document(self, node: DocumentNode, *_args: Any) -> VisitorAction:
4040
)
4141
self.report_error(
4242
GraphQLError(
43-
f"The {def_name} definition is not executable.", definition,
43+
f"The {def_name} definition is not executable.",
44+
definition,
4445
)
4546
)
4647
return SKIP

src/graphql/validation/rules/possible_type_extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class PossibleTypeExtensionsRule(SDLValidationRule):
2222
"""Possible type extension
2323
24-
A type extension is only valid if the type is defined and has the same kind.
24+
A type extension is only valid if the type is defined and has the same kind.
2525
"""
2626

2727
def __init__(self, context: SDLValidationContext):

tests/execution/test_executor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,10 @@ def errors_if_empty_string_is_provided_as_operation_name():
668668
document = parse("{ a }")
669669

670670
result = execute(schema, document, operation_name="")
671-
assert result == (None, [{"message": "Unknown operation named ''."}],)
671+
assert result == (
672+
None,
673+
[{"message": "Unknown operation named ''."}],
674+
)
672675

673676
def uses_the_query_schema_for_queries():
674677
schema = GraphQLSchema(

tests/execution/test_middleware.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,20 @@ def skip_middleware_without_resolve_method():
157157
class BadMiddleware:
158158
pass # no resolve method here
159159

160-
assert execute(
161-
GraphQLSchema(
162-
GraphQLObjectType("TestType", {"foo": GraphQLField(GraphQLString)},)
163-
),
164-
parse("{ foo }"),
165-
{"foo": "bar"},
166-
middleware=MiddlewareManager(BadMiddleware()),
167-
) == ({"foo": "bar"}, None)
160+
assert (
161+
execute(
162+
GraphQLSchema(
163+
GraphQLObjectType(
164+
"TestType",
165+
{"foo": GraphQLField(GraphQLString)},
166+
)
167+
),
168+
parse("{ foo }"),
169+
{"foo": "bar"},
170+
middleware=MiddlewareManager(BadMiddleware()),
171+
)
172+
== ({"foo": "bar"}, None)
173+
)
168174

169175
def with_function_and_object():
170176
doc = parse("{ field }")

tests/execution/test_resolve.py

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,35 @@ class RootValue:
2929
schema=_test_schema(GraphQLField(GraphQLString)),
3030
source="{ test }",
3131
root_value=RootValue(),
32-
) == ({"test": "testValue"}, None,)
32+
) == (
33+
{"test": "testValue"},
34+
None,
35+
)
3336

3437
def default_function_accesses_keys_of_dict():
3538
root_value = {"test": "testValue"}
3639

37-
assert graphql_sync(
38-
schema=_test_schema(GraphQLField(GraphQLString)),
39-
source="{ test }",
40-
root_value=root_value,
41-
) == ({"test": "testValue"}, None)
40+
assert (
41+
graphql_sync(
42+
schema=_test_schema(GraphQLField(GraphQLString)),
43+
source="{ test }",
44+
root_value=root_value,
45+
)
46+
== ({"test": "testValue"}, None)
47+
)
4248

4349
def default_function_accesses_keys_of_chain_map():
4450
# use a mapping that is not a subclass of dict
4551
root_value = ChainMap({"test": "testValue"})
4652

47-
assert graphql_sync(
48-
schema=_test_schema(GraphQLField(GraphQLString)),
49-
source="{ test }",
50-
root_value=root_value,
51-
) == ({"test": "testValue"}, None)
53+
assert (
54+
graphql_sync(
55+
schema=_test_schema(GraphQLField(GraphQLString)),
56+
source="{ test }",
57+
root_value=root_value,
58+
)
59+
== ({"test": "testValue"}, None)
60+
)
5261

5362
def default_function_calls_methods():
5463
class RootValue:
@@ -61,7 +70,10 @@ def test(self, _info):
6170
schema=_test_schema(GraphQLField(GraphQLString)),
6271
source="{ test }",
6372
root_value=RootValue(),
64-
) == ({"test": "secretValue"}, None,)
73+
) == (
74+
{"test": "secretValue"},
75+
None,
76+
)
6577

6678
def default_function_passes_args_and_context():
6779
class Adder:
@@ -90,7 +102,10 @@ class ContextValue:
90102
source=source,
91103
root_value=root_value,
92104
context_value=context_value,
93-
) == ({"test": 789}, None,)
105+
) == (
106+
{"test": 789},
107+
None,
108+
)
94109

95110
def uses_provided_resolve_function():
96111
schema = _test_schema(
@@ -114,7 +129,10 @@ def execute(source, root_value=None, context_value=None):
114129

115130
assert execute("{ test }") == ({"test": "[None, {}]"}, None)
116131

117-
assert execute("{ test }", "Source!") == ({"test": "['Source!', {}]"}, None,)
132+
assert execute("{ test }", "Source!") == (
133+
{"test": "['Source!', {}]"},
134+
None,
135+
)
118136

119137
assert execute('{ test(aStr: "String!") }', "Source!") == (
120138
{"test": "['Source!', {'aStr': 'String!'}]"},
@@ -144,7 +162,10 @@ def execute(source: str, root_value: Optional[Any] = None) -> ExecutionResult:
144162

145163
assert execute("{ test }") == ({"test": "[None, {}]"}, None)
146164

147-
assert execute("{ test }", "Source!") == ({"test": "['Source!', {}]"}, None,)
165+
assert execute("{ test }", "Source!") == (
166+
{"test": "['Source!', {}]"},
167+
None,
168+
)
148169

149170
assert execute('{ test(aStr: "String!") }', "Source!") == (
150171
{"test": "['Source!', {'a_str': 'String!'}]"},
@@ -177,7 +198,11 @@ def transforms_arguments_with_inputs_using_out_names():
177198
)
178199

179200
def execute(source, root_value=None):
180-
return graphql_sync(schema=schema, source=source, root_value=root_value,)
201+
return graphql_sync(
202+
schema=schema,
203+
source=source,
204+
root_value=root_value,
205+
)
181206

182207
assert execute("{ test }") == ({"test": "[None, {}]"}, None)
183208

tests/execution/test_union_interface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,10 @@ def resolve_type(_source, info, _type):
518518
document=document,
519519
root_value=root_value,
520520
context_value=context_value,
521-
) == ({"name": "John", "friends": [{"name": "Liz"}]}, None,)
521+
) == (
522+
{"name": "John", "friends": [{"name": "Liz"}]},
523+
None,
524+
)
522525

523526
assert encountered == {
524527
"schema": schema2,

tests/language/test_lexer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,17 @@ def lex_does_not_allow_name_start_after_a_number():
356356
"1_1234", "Invalid number, expected digit but got: '_'.", (1, 2)
357357
)
358358
assert_syntax_error(
359-
"1ß", "Cannot parse the unexpected character 'ß'.", (1, 2),
359+
"1ß",
360+
"Cannot parse the unexpected character 'ß'.",
361+
(1, 2),
360362
)
361363
assert_syntax_error(
362364
"1.23f", "Invalid number, expected digit but got: 'f'.", (1, 5)
363365
)
364366
assert_syntax_error(
365-
"12ß", "Cannot parse the unexpected character 'ß'.", (1, 3),
367+
"12ß",
368+
"Cannot parse the unexpected character 'ß'.",
369+
(1, 3),
366370
)
367371

368372
# noinspection PyArgumentEqualDefault

tests/subscription/test_subscribe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@ async def resolves_to_an_error_if_variables_were_wrong_type():
459459
)
460460

461461
result = await subscribe(
462-
schema=email_schema, document=ast, variable_values={"priority": "meow"},
462+
schema=email_schema,
463+
document=ast,
464+
variable_values={"priority": "meow"},
463465
)
464466

465467
assert result == (

tests/type/test_definition.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,17 +1552,14 @@ def resolve():
15521552
"SomeInputObject",
15531553
{
15541554
"f": GraphQLInputField( # type: ignore
1555-
ScalarType, resolve=resolve,
1555+
ScalarType,
1556+
resolve=resolve,
15561557
)
15571558
},
15581559
)
15591560
input_obj_type = GraphQLInputObjectType(
15601561
"SomeInputObject",
1561-
{
1562-
"f": GraphQLField( # type: ignore
1563-
ScalarType, resolve=resolve
1564-
)
1565-
},
1562+
{"f": GraphQLField(ScalarType, resolve=resolve)}, # type: ignore
15661563
)
15671564
with raises(TypeError) as exc_info:
15681565
if input_obj_type.fields:

tests/type/test_schema.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ def define_sample_schema():
9595
)
9696

9797
schema = GraphQLSchema(
98-
BlogQuery, BlogMutation, BlogSubscription, description="Sample schema",
98+
BlogQuery,
99+
BlogMutation,
100+
BlogSubscription,
101+
description="Sample schema",
99102
)
100103

101104
kwargs = schema.to_kwargs()
@@ -199,7 +202,9 @@ def includes_interfaces_thunk_subtypes_in_the_type_map():
199202
SomeSubtype = GraphQLObjectType(
200203
"SomeSubtype", {}, interfaces=lambda: [SomeInterface]
201204
)
202-
schema = GraphQLSchema(types=[SomeSubtype],)
205+
schema = GraphQLSchema(
206+
types=[SomeSubtype],
207+
)
203208
assert schema.type_map["SomeInterface"] is SomeInterface
204209
assert schema.type_map["AnotherInterface"] is AnotherInterface
205210
assert schema.type_map["SomeSubtype"] is SomeSubtype

tests/type/test_validation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,9 @@ def _schema_with_interface_field_of_type(field_type: GraphQLOutputType):
13381338
field.type = field_type
13391339
bad_interface_type = GraphQLInterfaceType("BadInterface", {"badField": field})
13401340
bad_implementing_type = GraphQLObjectType(
1341-
"BadImplementing", {"badField": field}, interfaces=[bad_interface_type],
1341+
"BadImplementing",
1342+
{"badField": field},
1343+
interfaces=[bad_interface_type],
13421344
)
13431345
return GraphQLSchema(
13441346
GraphQLObjectType("Query", {"f": GraphQLField(bad_interface_type)}),
@@ -1493,7 +1495,9 @@ def _schema_with_arg_of_type(arg_type: GraphQLInputType):
14931495
GraphQLObjectType("Query", {"f": GraphQLField(bad_object_type)}),
14941496
directives=[
14951497
GraphQLDirective(
1496-
"BadDirective", [DirectiveLocation.QUERY], {"badArg": argument},
1498+
"BadDirective",
1499+
[DirectiveLocation.QUERY],
1500+
{"badArg": argument},
14971501
)
14981502
],
14991503
)

tests/utilities/test_ast_from_value.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def converts_id_values_to_int_or_string_asts():
130130

131131
def converts_using_serialize_from_a_custom_scalar_type():
132132
pass_through_scalar = GraphQLScalarType(
133-
"PassThroughScalar", serialize=lambda value: value,
133+
"PassThroughScalar",
134+
serialize=lambda value: value,
134135
)
135136

136137
assert ast_from_value("value", pass_through_scalar) == StringValueNode(
@@ -146,7 +147,8 @@ def converts_using_serialize_from_a_custom_scalar_type():
146147
assert str(exc_info.value) == "Cannot convert value to AST: inf."
147148

148149
return_null_scalar = GraphQLScalarType(
149-
"ReturnNullScalar", serialize=lambda value: None,
150+
"ReturnNullScalar",
151+
serialize=lambda value: None,
150152
)
151153

152154
assert ast_from_value("value", return_null_scalar) is None
@@ -155,7 +157,8 @@ class SomeClass:
155157
pass
156158

157159
return_custom_class_scalar = GraphQLScalarType(
158-
"ReturnCustomClassScalar", serialize=lambda value: SomeClass(),
160+
"ReturnCustomClassScalar",
161+
serialize=lambda value: SomeClass(),
159162
)
160163

161164
with raises(TypeError) as exc_info:

tests/utilities/test_coerce_input_value.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,26 @@ def returns_an_error_for_a_non_dict_value():
168168
def returns_an_error_for_an_invalid_field():
169169
result = _coerce_value({"foo": nan}, TestInputObject)
170170
assert expect_errors(result) == [
171-
("Int cannot represent non-integer value: nan", ["foo"], nan,)
171+
(
172+
"Int cannot represent non-integer value: nan",
173+
["foo"],
174+
nan,
175+
)
172176
]
173177

174178
def returns_multiple_errors_for_multiple_invalid_fields():
175179
result = _coerce_value({"foo": "abc", "bar": "def"}, TestInputObject)
176180
assert expect_errors(result) == [
177-
("Int cannot represent non-integer value: 'abc'", ["foo"], "abc",),
178-
("Int cannot represent non-integer value: 'def'", ["bar"], "def",),
181+
(
182+
"Int cannot represent non-integer value: 'abc'",
183+
["foo"],
184+
"abc",
185+
),
186+
(
187+
"Int cannot represent non-integer value: 'def'",
188+
["bar"],
189+
"def",
190+
),
179191
]
180192

181193
def returns_error_for_a_missing_required_field():
@@ -275,8 +287,16 @@ def returns_no_error_for_a_valid_input():
275287
def returns_an_error_for_an_invalid_input():
276288
result = _coerce_value([1, "b", True, 4], TestList)
277289
assert expect_errors(result) == [
278-
("Int cannot represent non-integer value: 'b'", [1], "b",),
279-
("Int cannot represent non-integer value: True", [2], True,),
290+
(
291+
"Int cannot represent non-integer value: 'b'",
292+
[1],
293+
"b",
294+
),
295+
(
296+
"Int cannot represent non-integer value: True",
297+
[2],
298+
True,
299+
),
280300
]
281301

282302
def returns_a_list_for_a_non_list_value():

0 commit comments

Comments
 (0)