diff --git a/graphql/error/graphql_error.py b/graphql/error/graphql_error.py index f828999b..28291b77 100644 --- a/graphql/error/graphql_error.py +++ b/graphql/error/graphql_error.py @@ -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"] diff --git a/graphql/error/located_error.py b/graphql/error/located_error.py index 209c03ae..cc2ec7d6 100644 --- a/graphql/error/located_error.py +++ b/graphql/error/located_error.py @@ -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"] diff --git a/graphql/language/parser.py b/graphql/language/parser.py index c1e336ed..b9f77511 100644 --- a/graphql/language/parser.py +++ b/graphql/language/parser.py @@ -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) diff --git a/setup.py b/setup.py index 50f5d734..aa5e50f9 100644 --- a/setup.py +++ b/setup.py @@ -46,4 +46,3 @@ include_package_data=True, zip_safe=False, ) - diff --git a/tests/execution/test_mutations.py b/tests/execution/test_mutations.py index 9bbb591d..8e484089 100644 --- a/tests/execution/test_mutations.py +++ b/tests/execution/test_mutations.py @@ -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) ), ), }, diff --git a/tests/execution/test_variables.py b/tests/execution/test_variables.py index eb8d56a9..c06b2798 100644 --- a/tests/execution/test_variables.py +++ b/tests/execution/test_variables.py @@ -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( @@ -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, ) @@ -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, ) diff --git a/tests/language/test_printer.py b/tests/language/test_printer.py index eaf6cb46..c188b88c 100644 --- a/tests/language/test_printer.py +++ b/tests/language/test_printer.py @@ -195,4 +195,4 @@ def prints_kitchen_sink(kitchen_sink): # noqa: F811 query } ''' - ) # noqa + ) diff --git a/tests/language/test_schema_printer.py b/tests/language/test_schema_printer.py index 9b0497b5..9a1439ea 100644 --- a/tests/language/test_schema_printer.py +++ b/tests/language/test_schema_printer.py @@ -156,5 +156,5 @@ def prints_kitchen_sink(kitchen_sink): # noqa: F811 extend schema @onSchema { subscription: SubscriptionType } - ''' # noqa + ''' # noqa: E501 ) diff --git a/tests/type/test_enum.py b/tests/type/test_enum.py index 1b8ffac2..3b8b28d9 100644 --- a/tests/type/test_enum.py +++ b/tests/type/test_enum.py @@ -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"], } diff --git a/tests/type/test_introspection.py b/tests/type/test_introspection.py index 89ca6181..c6ac98ec 100644 --- a/tests/type/test_introspection.py +++ b/tests/type/test_introspection.py @@ -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.", }, ], } diff --git a/tests/type/test_validation.py b/tests/type/test_validation.py index 6a9f2987..960e343f 100644 --- a/tests/type/test_validation.py +++ b/tests/type/test_validation.py @@ -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 } @@ -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 } @@ -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} @@ -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)], }, ] @@ -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)], } ] diff --git a/tests/utilities/test_build_ast_schema.py b/tests/utilities/test_build_ast_schema.py index 8aa77604..0b35a8d4 100644 --- a/tests/utilities/test_build_ast_schema.py +++ b/tests/utilities/test_build_ast_schema.py @@ -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 @@ -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 diff --git a/tests/utilities/test_extend_schema.py b/tests/utilities/test_extend_schema.py index 5dc2f0f6..75ede7c8 100644 --- a/tests/utilities/test_extend_schema.py +++ b/tests/utilities/test_extend_schema.py @@ -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"] diff --git a/tests/utilities/test_find_breaking_changes.py b/tests/utilities/test_find_breaking_changes.py index 97223185..0c1f9f17 100644 --- a/tests/utilities/test_find_breaking_changes.py +++ b/tests/utilities/test_find_breaking_changes.py @@ -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 == [ ( @@ -799,7 +799,7 @@ def should_detect_all_breaking_changes(): field1: String } """ - ) # noqa + ) new_schema = build_schema( """ @@ -844,7 +844,7 @@ def should_detect_all_breaking_changes(): field1: String } """ - ) # noqa + ) expected_breaking_changes = [ (BreakingChangeType.TYPE_REMOVED, "Int was removed."), diff --git a/tests/utilities/test_lexicographic_sort_schema.py b/tests/utilities/test_lexicographic_sort_schema.py index 768c388b..9df620d9 100644 --- a/tests/utilities/test_lexicographic_sort_schema.py +++ b/tests/utilities/test_lexicographic_sort_schema.py @@ -10,8 +10,7 @@ def sort_sdl(sdl): def describe_lexicographic_sort_schema(): def sort_fields(): sorted_sdl = sort_sdl( - dedent( - """ + """ input Bar { barB: String barA: String @@ -34,7 +33,6 @@ def sort_fields(): dummy(arg: Bar): FooType } """ - ) ) assert sorted_sdl == dedent( @@ -65,8 +63,7 @@ def sort_fields(): def sort_implemented_interfaces(): sorted_sdl = sort_sdl( - dedent( - """ + """ interface FooA { dummy: String } @@ -83,7 +80,6 @@ def sort_implemented_interfaces(): dummy: String } """ - ) ) assert sorted_sdl == dedent( @@ -108,8 +104,7 @@ def sort_implemented_interfaces(): def sort_types_in_union(): sorted_sdl = sort_sdl( - dedent( - """ + """ type FooA { dummy: String } @@ -128,7 +123,6 @@ def sort_types_in_union(): dummy: FooUnion } """ - ) ) assert sorted_sdl == dedent( @@ -155,8 +149,7 @@ def sort_types_in_union(): def sort_enum_types(): sorted_sdl = sort_sdl( - dedent( - """ + """ enum Foo { B C @@ -167,7 +160,6 @@ def sort_enum_types(): dummy: Foo } """ - ) ) assert sorted_sdl == dedent( @@ -186,13 +178,11 @@ def sort_enum_types(): def sort_field_arguments(): sorted_sdl = sort_sdl( - dedent( - """ + """ type Query { dummy(argB: Int, argA: String, argC: Float): ID } """ - ) ) assert sorted_sdl == dedent( @@ -205,8 +195,7 @@ def sort_field_arguments(): def sort_types(): sorted_sdl = sort_sdl( - dedent( - """ + """ type Query { dummy(arg1: FooF, arg2: FooA, arg3: FooG): FooD } @@ -235,7 +224,6 @@ def sort_types(): dummy: String } """ - ) ) assert sorted_sdl == dedent( @@ -272,15 +260,13 @@ def sort_types(): def sort_directive_arguments(): sorted_sdl = sort_sdl( - dedent( - """ + """ directive @test(argC: Float, argA: String, argB: Int) on FIELD type Query { dummy: String } """ - ) ) assert sorted_sdl == dedent( @@ -295,15 +281,13 @@ def sort_directive_arguments(): def sort_directive_locations(): sorted_sdl = sort_sdl( - dedent( - """ + """ directive @test(argC: Float, argA: String, argB: Int) on UNION | FIELD | ENUM type Query { dummy: String } - """ # noqa - ) + """ # noqa: E501 ) assert sorted_sdl == dedent( @@ -313,13 +297,12 @@ def sort_directive_locations(): type Query { dummy: String } - """ # noqa + """ # noqa: E501 ) def sort_directives(): sorted_sdl = sort_sdl( - dedent( - """ + """ directive @fooC on FIELD directive @fooB on UNION @@ -330,7 +313,6 @@ def sort_directives(): dummy: String } """ - ) ) assert sorted_sdl == dedent( @@ -349,8 +331,7 @@ def sort_directives(): def sort_recursive_types(): sorted_sdl = sort_sdl( - dedent( - """ + """ interface FooC { fooB: FooB fooA: FooA @@ -373,7 +354,6 @@ def sort_recursive_types(): fooA: FooA } """ - ) ) assert sorted_sdl == dedent( diff --git a/tests/utilities/test_schema_printer.py b/tests/utilities/test_schema_printer.py index 7554f885..b242c478 100644 --- a/tests/utilities/test_schema_printer.py +++ b/tests/utilities/test_schema_printer.py @@ -244,7 +244,7 @@ def prints_string_field_with_multiple_args_first_is_default(): type Query { singleField(argOne: Int = 1, argTwo: String, argThree: Boolean): String } - """ # noqa + """ ) def prints_string_field_with_multiple_args_second_is_default(): @@ -263,7 +263,7 @@ def prints_string_field_with_multiple_args_second_is_default(): type Query { singleField(argOne: Int, argTwo: String = "foo", argThree: Boolean): String } - """ # noqa + """ # noqa: E501 ) def prints_string_field_with_multiple_args_last_is_default(): @@ -282,7 +282,7 @@ def prints_string_field_with_multiple_args_last_is_default(): type Query { singleField(argOne: Int, argTwo: String, argThree: Boolean = false): String } - """ # noqa + """ # noqa: E501 ) def prints_custom_query_root_type(): @@ -835,5 +835,5 @@ def prints_introspection_schema(): """Indicates this type is a non-null. `ofType` is a valid field.""" NON_NULL } - ''' # noqa + ''' # noqa: E501 ) diff --git a/tests/validation/test_known_directives.py b/tests/validation/test_known_directives.py index 9d97f82c..1cc1edbc 100644 --- a/tests/validation/test_known_directives.py +++ b/tests/validation/test_known_directives.py @@ -310,7 +310,7 @@ def with_well_placed_directives(): } extend schema @onSchema - """, # noqa + """, schema_with_sdl_directives, ) == [] @@ -345,7 +345,7 @@ def with_misplaced_directives(): } extend schema @onObject - """, # noqa + """, # noqa: E501 schema_with_sdl_directives, ) == [ diff --git a/tests/validation/test_possible_fragment_spreads.py b/tests/validation/test_possible_fragment_spreads.py index 5fbedf5f..c5b9008f 100644 --- a/tests/validation/test_possible_fragment_spreads.py +++ b/tests/validation/test_possible_fragment_spreads.py @@ -37,7 +37,7 @@ def of_the_same_object_inline_fragment(): """ fragment objectWithinObjectAnon on Dog { ... on Dog { barkVolume } } """, - ) # noqa + ) def object_into_implemented_interface(): expect_passes_rule( @@ -186,7 +186,7 @@ def union_into_non_overlapping_interface(): fragment invalidUnionWithinInterface on Pet { ...humanOrAlienFragment } fragment humanOrAlienFragment on HumanOrAlien { __typename } """, - [error("humanOrAlienFragment", "Pet", "HumanOrAlien", 2, 59)], # noqa + [error("humanOrAlienFragment", "Pet", "HumanOrAlien", 2, 59)], ) def union_into_non_overlapping_union(): @@ -196,7 +196,7 @@ def union_into_non_overlapping_union(): fragment invalidUnionWithinUnion on CatOrDog { ...humanOrAlienFragment } fragment humanOrAlienFragment on HumanOrAlien { __typename } """, - [error("humanOrAlienFragment", "CatOrDog", "HumanOrAlien", 2, 60)], # noqa + [error("humanOrAlienFragment", "CatOrDog", "HumanOrAlien", 2, 60)], ) def interface_into_non_implementing_object(): @@ -206,7 +206,7 @@ def interface_into_non_implementing_object(): fragment invalidInterfaceWithinObject on Cat { ...intelligentFragment } fragment intelligentFragment on Intelligent { iq } """, - [error("intelligentFragment", "Cat", "Intelligent", 2, 60)], # noqa + [error("intelligentFragment", "Cat", "Intelligent", 2, 60)], ) def interface_into_non_overlapping_interface(): @@ -239,5 +239,5 @@ def interface_into_non_overlapping_union(): fragment invalidInterfaceWithinUnion on HumanOrAlien { ...petFragment } fragment petFragment on Pet { name } """, - [error("petFragment", "HumanOrAlien", "Pet", 2, 68)], # noqa + [error("petFragment", "HumanOrAlien", "Pet", 2, 68)], ) diff --git a/tests/validation/test_provided_required_arguments.py b/tests/validation/test_provided_required_arguments.py index e48552d5..54b2315a 100644 --- a/tests/validation/test_provided_required_arguments.py +++ b/tests/validation/test_provided_required_arguments.py @@ -269,7 +269,7 @@ def missing_optional_args_on_directive_defined_inside_sdl(): """ ) == [] - ) # noqa + ) def missing_arg_on_directive_defined_inside_sdl(): assert ( diff --git a/tests/validation/test_values_of_correct_type.py b/tests/validation/test_values_of_correct_type.py index d2709471..b59c6bcc 100644 --- a/tests/validation/test_values_of_correct_type.py +++ b/tests/validation/test_values_of_correct_type.py @@ -184,7 +184,7 @@ def null_into_nullable_type(): } } """, - ) # noqa + ) def describe_invalid_string_values(): def int_into_string(): @@ -809,7 +809,7 @@ def partial_object_including_required(): } } """, - ) # noqa + ) def full_object(): expect_passes_rule(