Skip to content

Commit 448d045

Browse files
committed
Update ruff and adapt code style
1 parent 4933704 commit 448d045

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+258
-212
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ tox = [
7575
optional = true
7676

7777
[tool.poetry.group.lint.dependencies]
78-
ruff = ">=0.5.7,<0.6"
78+
ruff = ">=0.6.4,<0.7"
7979
mypy = [
8080
{ version = "^1.11", python = ">=3.8" },
8181
{ version = "~1.4", python = "<3.8" }

src/graphql/execution/execute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
anext # noqa: B018
9797
except NameError: # pragma: no cover (Python < 3.10)
9898
# noinspection PyShadowingBuiltins
99-
async def anext(iterator: AsyncIterator) -> Any: # noqa: A001
99+
async def anext(iterator: AsyncIterator) -> Any:
100100
"""Return the next item from an async iterator."""
101101
return await iterator.__anext__()
102102

src/graphql/pyutils/suggestion_list.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ def measure(self, option: str, threshold: int) -> int | None:
9999
double_diagonal_cell = rows[(i - 2) % 3][j - 2]
100100
current_cell = min(current_cell, double_diagonal_cell + 1)
101101

102-
if current_cell < smallest_cell:
103-
smallest_cell = current_cell
102+
smallest_cell = min(current_cell, smallest_cell)
104103

105104
current_row[j] = current_cell
106105

tests/execution/test_abstract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Any, NamedTuple
44

55
import pytest
6+
67
from graphql.execution import ExecutionResult, execute, execute_sync
78
from graphql.language import parse
89
from graphql.pyutils import is_awaitable

tests/execution/test_customize.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from inspect import isasyncgen
22

33
import pytest
4+
45
from graphql.execution import ExecutionContext, execute, subscribe
56
from graphql.language import parse
67
from graphql.type import GraphQLField, GraphQLObjectType, GraphQLSchema, GraphQLString
@@ -9,7 +10,7 @@
910
anext # noqa: B018
1011
except NameError: # pragma: no cover (Python < 3.10)
1112
# noinspection PyShadowingBuiltins
12-
async def anext(iterator): # noqa: A001
13+
async def anext(iterator):
1314
"""Return the next item from an async iterator."""
1415
return await iterator.__anext__()
1516

@@ -62,7 +63,7 @@ def execute_field(
6263

6364

6465
def describe_customize_subscription():
65-
@pytest.mark.asyncio()
66+
@pytest.mark.asyncio
6667
async def uses_a_custom_subscribe_field_resolver():
6768
schema = GraphQLSchema(
6869
query=GraphQLObjectType("Query", {"foo": GraphQLField(GraphQLString)}),
@@ -91,7 +92,7 @@ async def custom_foo():
9192

9293
await subscription.aclose()
9394

94-
@pytest.mark.asyncio()
95+
@pytest.mark.asyncio
9596
async def uses_a_custom_execution_context_class():
9697
class TestExecutionContext(ExecutionContext):
9798
def build_resolve_info(self, *args, **kwargs):

tests/execution/test_defer.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Any, AsyncGenerator, NamedTuple
55

66
import pytest
7+
78
from graphql.error import GraphQLError
89
from graphql.execution import (
910
ExecutionResult,
@@ -333,7 +334,7 @@ def can_print_deferred_fragment_record():
333334
"path=['bar'], label='foo', parent_context, data)"
334335
)
335336

336-
@pytest.mark.asyncio()
337+
@pytest.mark.asyncio
337338
async def can_defer_fragments_containing_scalar_types():
338339
document = parse(
339340
"""
@@ -358,7 +359,7 @@ async def can_defer_fragments_containing_scalar_types():
358359
},
359360
]
360361

361-
@pytest.mark.asyncio()
362+
@pytest.mark.asyncio
362363
async def can_disable_defer_using_if_argument():
363364
document = parse(
364365
"""
@@ -384,7 +385,7 @@ async def can_disable_defer_using_if_argument():
384385
},
385386
}
386387

387-
@pytest.mark.asyncio()
388+
@pytest.mark.asyncio
388389
async def does_not_disable_defer_with_null_if_argument():
389390
document = parse(
390391
"""
@@ -409,7 +410,7 @@ async def does_not_disable_defer_with_null_if_argument():
409410
},
410411
]
411412

412-
@pytest.mark.asyncio()
413+
@pytest.mark.asyncio
413414
async def throws_an_error_for_defer_directive_with_non_string_label():
414415
document = parse(
415416
"""
@@ -430,7 +431,7 @@ async def throws_an_error_for_defer_directive_with_non_string_label():
430431
],
431432
}
432433

433-
@pytest.mark.asyncio()
434+
@pytest.mark.asyncio
434435
async def can_defer_fragments_on_the_top_level_query_field():
435436
document = parse(
436437
"""
@@ -456,7 +457,7 @@ async def can_defer_fragments_on_the_top_level_query_field():
456457
},
457458
]
458459

459-
@pytest.mark.asyncio()
460+
@pytest.mark.asyncio
460461
async def can_defer_fragments_with_errors_on_the_top_level_query_field():
461462
document = parse(
462463
"""
@@ -493,7 +494,7 @@ async def can_defer_fragments_with_errors_on_the_top_level_query_field():
493494
},
494495
]
495496

496-
@pytest.mark.asyncio()
497+
@pytest.mark.asyncio
497498
async def can_defer_a_fragment_within_an_already_deferred_fragment():
498499
document = parse(
499500
"""
@@ -540,7 +541,7 @@ async def can_defer_a_fragment_within_an_already_deferred_fragment():
540541
},
541542
]
542543

543-
@pytest.mark.asyncio()
544+
@pytest.mark.asyncio
544545
async def can_defer_a_fragment_that_is_also_not_deferred_with_deferred_first():
545546
document = parse(
546547
"""
@@ -571,7 +572,7 @@ async def can_defer_a_fragment_that_is_also_not_deferred_with_deferred_first():
571572
},
572573
]
573574

574-
@pytest.mark.asyncio()
575+
@pytest.mark.asyncio
575576
async def can_defer_a_fragment_that_is_also_not_deferred_with_non_deferred_first():
576577
document = parse(
577578
"""
@@ -602,7 +603,7 @@ async def can_defer_a_fragment_that_is_also_not_deferred_with_non_deferred_first
602603
},
603604
]
604605

605-
@pytest.mark.asyncio()
606+
@pytest.mark.asyncio
606607
async def can_defer_an_inline_fragment():
607608
document = parse(
608609
"""
@@ -632,7 +633,7 @@ async def can_defer_an_inline_fragment():
632633
},
633634
]
634635

635-
@pytest.mark.asyncio()
636+
@pytest.mark.asyncio
636637
async def handles_errors_thrown_in_deferred_fragments():
637638
document = parse(
638639
"""
@@ -669,7 +670,7 @@ async def handles_errors_thrown_in_deferred_fragments():
669670
},
670671
]
671672

672-
@pytest.mark.asyncio()
673+
@pytest.mark.asyncio
673674
async def handles_non_nullable_errors_thrown_in_deferred_fragments():
674675
document = parse(
675676
"""
@@ -709,7 +710,7 @@ async def handles_non_nullable_errors_thrown_in_deferred_fragments():
709710
},
710711
]
711712

712-
@pytest.mark.asyncio()
713+
@pytest.mark.asyncio
713714
async def handles_non_nullable_errors_thrown_outside_deferred_fragments():
714715
document = parse(
715716
"""
@@ -740,7 +741,7 @@ async def handles_non_nullable_errors_thrown_outside_deferred_fragments():
740741
],
741742
}
742743

743-
@pytest.mark.asyncio()
744+
@pytest.mark.asyncio
744745
async def handles_async_non_nullable_errors_thrown_in_deferred_fragments():
745746
document = parse(
746747
"""
@@ -780,7 +781,7 @@ async def handles_async_non_nullable_errors_thrown_in_deferred_fragments():
780781
},
781782
]
782783

783-
@pytest.mark.asyncio()
784+
@pytest.mark.asyncio
784785
async def returns_payloads_in_correct_order():
785786
document = parse(
786787
"""
@@ -833,7 +834,7 @@ async def returns_payloads_in_correct_order():
833834
},
834835
]
835836

836-
@pytest.mark.asyncio()
837+
@pytest.mark.asyncio
837838
async def returns_payloads_from_synchronous_data_in_correct_order():
838839
document = parse(
839840
"""
@@ -886,7 +887,7 @@ async def returns_payloads_from_synchronous_data_in_correct_order():
886887
},
887888
]
888889

889-
@pytest.mark.asyncio()
890+
@pytest.mark.asyncio
890891
async def filters_deferred_payloads_when_list_item_from_async_iterable_nulled():
891892
document = parse(
892893
"""
@@ -920,7 +921,7 @@ async def filters_deferred_payloads_when_list_item_from_async_iterable_nulled():
920921
],
921922
}
922923

923-
@pytest.mark.asyncio()
924+
@pytest.mark.asyncio
924925
async def original_execute_function_throws_error_if_deferred_and_all_is_sync():
925926
document = parse(
926927
"""
@@ -938,7 +939,7 @@ async def original_execute_function_throws_error_if_deferred_and_all_is_sync():
938939
" multiple payloads (due to @defer or @stream directive)"
939940
)
940941

941-
@pytest.mark.asyncio()
942+
@pytest.mark.asyncio
942943
async def original_execute_function_throws_error_if_deferred_and_not_all_is_sync():
943944
document = parse(
944945
"""

tests/execution/test_execution_result.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
from graphql.error import GraphQLError
34
from graphql.execution import ExecutionResult
45

tests/execution/test_executor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Any, Awaitable, cast
55

66
import pytest
7+
78
from graphql.error import GraphQLError
89
from graphql.execution import execute, execute_sync
910
from graphql.language import FieldNode, OperationDefinitionNode, parse
@@ -41,7 +42,7 @@ def accepts_positional_arguments():
4142

4243
assert result == ({"a": "rootValue"}, None)
4344

44-
@pytest.mark.asyncio()
45+
@pytest.mark.asyncio
4546
async def executes_arbitrary_code():
4647
# noinspection PyMethodMayBeStatic,PyMethodMayBeStatic
4748
class Data:
@@ -375,7 +376,7 @@ def resolve(_obj, _info, **args):
375376
assert len(resolved_args) == 1
376377
assert resolved_args[0] == {"numArg": 123, "stringArg": "foo"}
377378

378-
@pytest.mark.asyncio()
379+
@pytest.mark.asyncio
379380
async def nulls_out_error_subtrees():
380381
document = parse(
381382
"""
@@ -868,7 +869,7 @@ def resolves_to_an_error_if_schema_does_not_support_operation():
868869
],
869870
)
870871

871-
@pytest.mark.asyncio()
872+
@pytest.mark.asyncio
872873
async def correct_field_ordering_despite_execution_order():
873874
schema = GraphQLSchema(
874875
GraphQLObjectType(
@@ -984,7 +985,7 @@ def does_not_include_arguments_that_were_not_set():
984985
None,
985986
)
986987

987-
@pytest.mark.asyncio()
988+
@pytest.mark.asyncio
988989
async def fails_when_is_type_of_check_is_not_met():
989990
class Special:
990991
value: str

0 commit comments

Comments
 (0)