Skip to content

Commit

Permalink
Some adaptations to long lines after reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Sep 19, 2018
1 parent 1bcd466 commit ea0c52a
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 102 deletions.
6 changes: 3 additions & 3 deletions graphql/error/graphql_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from .print_error import print_error

if TYPE_CHECKING: # pragma: no cover
from ..language.ast import Node # noqa
from ..language.location import SourceLocation # noqa
from ..language.source import Source # noqa
from ..language.ast import Node # noqa: F401
from ..language.location import SourceLocation # noqa: F401
from ..language.source import Source # noqa: F401

__all__ = ["GraphQLError"]

Expand Down
2 changes: 1 addition & 1 deletion graphql/error/located_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .graphql_error import GraphQLError

if TYPE_CHECKING: # pragma: no cover
from ..language.ast import Node # noqa
from ..language.ast import Node # noqa: F401

__all__ = ["located_error"]

Expand Down
4 changes: 3 additions & 1 deletion graphql/language/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def parse(
source,
no_location=no_location,
experimental_fragment_variables=experimental_fragment_variables,
experimental_variable_definition_directives=experimental_variable_definition_directives, # noqa
experimental_variable_definition_directives=(
experimental_variable_definition_directives
),
)
return parse_document(lexer)

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@
include_package_data=True,
zip_safe=False,
)

4 changes: 2 additions & 2 deletions tests/execution/test_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ async def promise_and_fail_to_change_the_number(self, newNumber: int):
"promiseAndFailToChangeTheNumber": GraphQLField(
numberHolderType,
args={"newNumber": GraphQLArgument(GraphQLInt)},
resolve=lambda obj, _info, newNumber: obj.promise_and_fail_to_change_the_number( # noqa
newNumber
resolve=lambda obj, _info, newNumber: (
obj.promise_and_fail_to_change_the_number(newNumber)
),
),
},
Expand Down
13 changes: 6 additions & 7 deletions tests/execution/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def field_with_input_arg(input_arg: GraphQLArgument):
"fieldWithDefaultArgumentValue": field_with_input_arg(
GraphQLArgument(GraphQLString, default_value="Hello World")
),
"fieldWithNonNullableStringInputAndDefaultArgumentValue": field_with_input_arg(
"fieldWithNonNullableStringInputAndDefaultArgValue": field_with_input_arg(
GraphQLArgument(GraphQLNonNull(GraphQLString), default_value="Hello World")
),
"fieldWithNestedInputObject": field_with_input_arg(
Expand Down Expand Up @@ -162,7 +162,8 @@ def properly_parses_null_value_to_null():

assert result == (
{
"fieldWithObjectInput": "{'a': None, 'b': None, 'c': 'C', 'd': None}" # noqa
"fieldWithObjectInput": "{'a': None, 'b': None,"
" 'c': 'C', 'd': None}"
},
None,
)
Expand Down Expand Up @@ -907,14 +908,12 @@ def when_no_runtime_value_is_provided_to_a_non_null_argument():
result = execute_query(
"""
query optionalVariable($optional: String) {
fieldWithNonNullableStringInputAndDefaultArgumentValue(input: $optional)
fieldWithNonNullableStringInputAndDefaultArgValue(input: $optional)
}
""" # noqa
"""
)

assert result == (
{
"fieldWithNonNullableStringInputAndDefaultArgumentValue": "'Hello World'" # noqa
},
{"fieldWithNonNullableStringInputAndDefaultArgValue": "'Hello World'"},
None,
)
2 changes: 1 addition & 1 deletion tests/language/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ def prints_kitchen_sink(kitchen_sink): # noqa: F811
query
}
'''
) # noqa
)
2 changes: 1 addition & 1 deletion tests/language/test_schema_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,5 @@ def prints_kitchen_sink(kitchen_sink): # noqa: F811
extend schema @onSchema {
subscription: SubscriptionType
}
''' # noqa
''' # noqa: E501
)
3 changes: 2 additions & 1 deletion tests/type/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def may_be_internally_represented_with_complex_values():
{"first": "ONE", "second": "TWO", "good": "TWO", "bad": None},
[
{
"message": "Expected a value of type 'Complex' but received: Complex2", # noqa
"message": "Expected a value of type 'Complex'"
" but received: Complex2",
"locations": [(6, 15)],
"path": ["bad"],
}
Expand Down
17 changes: 10 additions & 7 deletions tests/type/test_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,25 +1214,28 @@ def exposes_descriptions_on_types_and_fields():
"fields": [
{
"name": "types",
"description": "A list of all types supported by this server.", # noqa
"description": "A list of all types supported"
" by this server.",
},
{
"name": "queryType",
"description": "The type that query operations will be rooted at.", # noqa
"description": "The type that query operations"
" will be rooted at.",
},
{
"name": "mutationType",
"description": "If this server supports mutation, the type that" # noqa
" mutation operations will be rooted at.", # noqa
"description": "If this server supports mutation, the type"
" that mutation operations will be rooted at.",
},
{
"name": "subscriptionType",
"description": "If this server support subscription, the type" # noqa
" that subscription operations will be rooted at.", # noqa
"description": "If this server support subscription,"
" the type that subscription operations will be rooted at.",
},
{
"name": "directives",
"description": "A list of all directives supported by this server.", # noqa
"description": "A list of all directives supported"
" by this server.",
},
],
}
Expand Down
50 changes: 25 additions & 25 deletions tests/type/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def accepts_a_schema_whose_query_and_mutation_types_are_object_types():

schema_with_def = build_schema(
"""
schema {
schema {
query: QueryRoot
mutation: MutationRoot
}
Expand Down Expand Up @@ -165,7 +165,7 @@ def accepts_a_schema_whose_query_and_subscription_types_are_object_types():

schema_with_def = build_schema(
"""
schema {
schema {
query: QueryRoot
subscription: SubscriptionRoot
}
Expand All @@ -184,10 +184,10 @@ def accepts_a_schema_whose_query_and_subscription_types_are_object_types():
def rejects_a_schema_without_a_query_type():
schema = build_schema(
"""
type Mutation {
test: String
}
"""
type Mutation {
test: String
}
"""
)
assert validate_schema(schema) == [
{"message": "Query root type must be provided.", "locations": None}
Expand Down Expand Up @@ -343,47 +343,47 @@ def rejects_a_schema_extended_with_invalid_root_types():
schema,
parse(
"""
extend schema {
query: SomeInputObject
}
"""
extend schema {
query: SomeInputObject
}
"""
),
)
schema = extend_schema(
schema,
parse(
"""
extend schema {
mutation: SomeInputObject
}
"""
extend schema {
mutation: SomeInputObject
}
"""
),
)
schema = extend_schema(
schema,
parse(
"""
extend schema {
subscription: SomeInputObject
}
"""
extend schema {
subscription: SomeInputObject
}
"""
),
)
assert validate_schema(schema) == [
{
"message": "Query root type must be Object type,"
" it cannot be SomeInputObject.",
"locations": [(3, 22)],
"locations": [(3, 26)],
},
{
"message": "Mutation root type must be Object type"
" if provided, it cannot be SomeInputObject.",
"locations": [(3, 25)],
"locations": [(3, 29)],
},
{
"message": "Subscription root type must be Object type"
" if provided, it cannot be SomeInputObject.",
"locations": [(3, 29)],
"locations": [(3, 33)],
},
]

Expand Down Expand Up @@ -521,17 +521,17 @@ def rejects_a_union_type_with_empty_types():
schema,
parse(
"""
directive @test on UNION
directive @test on UNION
extend union BadUnion @test
"""
extend union BadUnion @test
"""
),
)
assert validate_schema(schema) == [
{
"message": "Union type BadUnion must define one or more"
" member types.",
"locations": [(6, 13), (4, 13)],
"locations": [(6, 13), (4, 17)],
}
]

Expand Down
4 changes: 2 additions & 2 deletions tests/utilities/test_build_ast_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def simple_type_with_mutation():
addHelloScalars(str: String, int: Int, bool: Boolean): HelloScalars
}
"""
) # noqa
)
output = cycle_output(body)
assert output == body

Expand All @@ -575,7 +575,7 @@ def simple_type_with_subscription():
subscribeHelloScalars(str: String, int: Int, bool: Boolean): HelloScalars
}
"""
) # noqa
)
output = cycle_output(body)
assert output == body

Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/test_extend_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def builds_types_with_deprecated_fields_and_values():
DEPRECATED @deprecated(reason: "do not use")
}
"""
) # noqa
)
deprecated_field_def = extended_schema.get_type(
"TypeWithDeprecatedField"
).fields["newDeprecatedField"]
Expand Down
6 changes: 3 additions & 3 deletions tests/utilities/test_find_breaking_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def should_detect_if_a_required_field_argument_was_added():
field1: String
}
"""
) # noqa
)

assert find_arg_changes(old_schema, new_schema).breaking_changes == [
(
Expand Down Expand Up @@ -799,7 +799,7 @@ def should_detect_all_breaking_changes():
field1: String
}
"""
) # noqa
)

new_schema = build_schema(
"""
Expand Down Expand Up @@ -844,7 +844,7 @@ def should_detect_all_breaking_changes():
field1: String
}
"""
) # noqa
)

expected_breaking_changes = [
(BreakingChangeType.TYPE_REMOVED, "Int was removed."),
Expand Down
Loading

0 comments on commit ea0c52a

Please sign in to comment.