|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | from asyncio import ( |
6 | | - CancelledError, |
7 | 6 | TimeoutError, # only needed for Python < 3.11 # noqa: A004 |
8 | 7 | ensure_future, |
9 | 8 | sleep, |
|
108 | 107 | from .values import get_argument_values, get_directive_values, get_variable_values |
109 | 108 |
|
110 | 109 | if TYPE_CHECKING: |
111 | | - from ..pyutils import UndefinedType |
112 | | - |
113 | | - try: |
114 | | - from typing import TypeAlias, TypeGuard |
115 | | - except ImportError: # Python < 3.10 |
116 | | - from typing_extensions import TypeAlias, TypeGuard |
117 | | - |
118 | | -try: # pragma: no cover |
119 | | - anext # noqa: B018 # pyright: ignore |
120 | | -except NameError: # pragma: no cover (Python < 3.10) |
121 | | - |
122 | | - async def anext(iterator: AsyncIterator) -> Any: |
123 | | - """Return the next item from an async iterator.""" |
124 | | - return await iterator.__anext__() |
| 110 | + from typing import TypeAlias, TypeGuard |
125 | 111 |
|
| 112 | + from ..pyutils import UndefinedType |
126 | 113 |
|
127 | 114 | __all__ = [ |
128 | 115 | "ExecutionContext", |
@@ -577,7 +564,7 @@ async def get_results() -> GraphQLWrappedResult[dict[str, Any]]: |
577 | 564 | awaited_results = await gather_with_cancel( |
578 | 565 | *(results[field] for field in awaitable_fields) |
579 | 566 | ) |
580 | | - results.update(zip(awaitable_fields, awaited_results)) |
| 567 | + results.update(zip(awaitable_fields, awaited_results, strict=True)) |
581 | 568 |
|
582 | 569 | return GraphQLWrappedResult(results, graphql_wrapped_result.increments) |
583 | 570 |
|
@@ -654,10 +641,6 @@ async def await_completed() -> Any: |
654 | 641 | try: |
655 | 642 | return await completed |
656 | 643 | except Exception as raw_error: |
657 | | - # Before Python 3.8 CancelledError inherits Exception and |
658 | | - # so gets caught here. |
659 | | - if isinstance(raw_error, CancelledError): |
660 | | - raise # pragma: no cover |
661 | 644 | self.handle_field_error( |
662 | 645 | raw_error, |
663 | 646 | return_type, |
@@ -867,10 +850,6 @@ async def complete_awaitable_value( |
867 | 850 | if self.is_awaitable(completed): |
868 | 851 | completed = await completed |
869 | 852 | except Exception as raw_error: |
870 | | - # Before Python 3.8 CancelledError inherits Exception and |
871 | | - # so gets caught here. |
872 | | - if isinstance(raw_error, CancelledError): |
873 | | - raise # pragma: no cover |
874 | 853 | self.handle_field_error( |
875 | 854 | raw_error, return_type, field_group, path, incremental_context |
876 | 855 | ) |
@@ -1040,7 +1019,9 @@ async def complete_async_iterator_value( |
1040 | 1019 | awaited_results = await gather_with_cancel( |
1041 | 1020 | *(completed_results[index] for index in awaitable_indices) |
1042 | 1021 | ) |
1043 | | - for index, sub_result in zip(awaitable_indices, awaited_results): |
| 1022 | + for index, sub_result in zip( |
| 1023 | + awaitable_indices, awaited_results, strict=True |
| 1024 | + ): |
1044 | 1025 | completed_results[index] = sub_result |
1045 | 1026 | return GraphQLWrappedResult( |
1046 | 1027 | completed_results, graphql_wrapped_result.increments |
@@ -1186,7 +1167,9 @@ async def get_completed_results() -> GraphQLWrappedResult[list[Any]]: |
1186 | 1167 | awaited_results = await gather_with_cancel( |
1187 | 1168 | *(completed_results[index] for index in awaitable_indices) |
1188 | 1169 | ) |
1189 | | - for index, sub_result in zip(awaitable_indices, awaited_results): |
| 1170 | + for index, sub_result in zip( |
| 1171 | + awaitable_indices, awaited_results, strict=True |
| 1172 | + ): |
1190 | 1173 | completed_results[index] = sub_result |
1191 | 1174 | return GraphQLWrappedResult( |
1192 | 1175 | completed_results, graphql_wrapped_result.increments |
@@ -2449,7 +2432,9 @@ def default_type_resolver( |
2449 | 2432 |
|
2450 | 2433 | async def get_type() -> str | None: |
2451 | 2434 | is_type_of_results = await gather_with_cancel(*awaitable_is_type_of_results) |
2452 | | - for is_type_of_result, type_ in zip(is_type_of_results, awaitable_types): |
| 2435 | + for is_type_of_result, type_ in zip( |
| 2436 | + is_type_of_results, awaitable_types, strict=True |
| 2437 | + ): |
2453 | 2438 | if is_type_of_result: |
2454 | 2439 | return type_.name |
2455 | 2440 | return None |
|
0 commit comments