Skip to content

Commit 1e2589e

Browse files
committed
polish: rename MapAsyncIterator to MapAsyncIterable
Replicates graphql/graphql-js@4822cb4
1 parent b499445 commit 1e2589e

File tree

10 files changed

+81
-81
lines changed

10 files changed

+81
-81
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
GraphQLOutputType
149149
Middleware
150150
asyncio.events.AbstractEventLoop
151-
graphql.execution.map_async_iterator.MapAsyncIterator
151+
graphql.execution.map_async_iterable.MapAsyncIterable
152152
graphql.execution.Middleware
153153
graphql.language.lexer.EscapeSequence
154154
graphql.language.visitor.EnterLeaveVisitor

docs/modules/execution.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Execution
2626

2727
.. autofunction:: create_source_event_stream
2828

29-
.. autoclass:: MapAsyncIterator
29+
.. autoclass:: MapAsyncIterable
3030

3131
.. autoclass:: Middleware
3232

src/graphql/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@
437437
# Subscription
438438
subscribe,
439439
create_source_event_stream,
440-
MapAsyncIterator,
440+
MapAsyncIterable,
441441
# Middleware
442442
Middleware,
443443
MiddlewareManager,
@@ -703,7 +703,7 @@
703703
"MiddlewareManager",
704704
"subscribe",
705705
"create_source_event_stream",
706-
"MapAsyncIterator",
706+
"MapAsyncIterable",
707707
"validate",
708708
"ValidationContext",
709709
"ValidationRule",

src/graphql/execution/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
FormattedExecutionResult,
1717
Middleware,
1818
)
19-
from .map_async_iterator import MapAsyncIterator
19+
from .map_async_iterable import MapAsyncIterable
2020
from .middleware import MiddlewareManager
2121
from .values import get_argument_values, get_directive_values, get_variable_values
2222

@@ -30,7 +30,7 @@
3030
"ExecutionContext",
3131
"ExecutionResult",
3232
"FormattedExecutionResult",
33-
"MapAsyncIterator",
33+
"MapAsyncIterable",
3434
"Middleware",
3535
"MiddlewareManager",
3636
"get_argument_values",

src/graphql/execution/execute.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
is_object_type,
6060
)
6161
from .collect_fields import collect_fields, collect_subfields
62-
from .map_async_iterator import MapAsyncIterator
62+
from .map_async_iterable import MapAsyncIterable
6363
from .middleware import MiddlewareManager
6464
from .values import get_argument_values, get_variable_values
6565

@@ -1371,15 +1371,15 @@ async def await_result() -> Any:
13711371
result_or_stream = await awaitable_result_or_stream
13721372
if isinstance(result_or_stream, ExecutionResult):
13731373
return result_or_stream
1374-
return MapAsyncIterator(result_or_stream, map_source_to_response)
1374+
return MapAsyncIterable(result_or_stream, map_source_to_response)
13751375

13761376
return await_result()
13771377

13781378
if isinstance(result_or_stream, ExecutionResult):
13791379
return result_or_stream
13801380

13811381
# Map every source value to a ExecutionResult value as described above.
1382-
return MapAsyncIterator(
1382+
return MapAsyncIterable(
13831383
cast(AsyncIterable[Any], result_or_stream), map_source_to_response
13841384
)
13851385

src/graphql/execution/map_async_iterator.py renamed to src/graphql/execution/map_async_iterable.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from typing import Any, AsyncIterable, Callable, Optional, Set, Type, Union, cast
88

99

10-
__all__ = ["MapAsyncIterator"]
10+
__all__ = ["MapAsyncIterable"]
1111

1212

1313
# noinspection PyAttributeOutsideInit
14-
class MapAsyncIterator:
14+
class MapAsyncIterable:
1515
"""Map an AsyncIterable over a callback function.
1616
1717
Given an AsyncIterable and a callback function, return an AsyncIterator which
@@ -26,7 +26,7 @@ def __init__(self, iterable: AsyncIterable, callback: Callable) -> None:
2626
self.callback = callback
2727
self._close_event = Event()
2828

29-
def __aiter__(self) -> MapAsyncIterator:
29+
def __aiter__(self) -> MapAsyncIterable:
3030
"""Get the iterator object."""
3131
return self
3232

tests/execution/test_customize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pytest import mark
22

3-
from graphql.execution import ExecutionContext, MapAsyncIterator, execute, subscribe
3+
from graphql.execution import ExecutionContext, MapAsyncIterable, execute, subscribe
44
from graphql.language import parse
55
from graphql.type import GraphQLField, GraphQLObjectType, GraphQLSchema, GraphQLString
66

@@ -73,7 +73,7 @@ async def custom_foo():
7373
root_value=Root(),
7474
subscribe_field_resolver=lambda root, _info: root.custom_foo(),
7575
)
76-
assert isinstance(subscription, MapAsyncIterator)
76+
assert isinstance(subscription, MapAsyncIterable)
7777

7878
assert await anext(subscription) == (
7979
{"foo": "FooValue"},
@@ -117,6 +117,6 @@ def resolve_foo(message, _info):
117117
context_value={},
118118
execution_context_class=TestExecutionContext,
119119
)
120-
assert isinstance(subscription, MapAsyncIterator)
120+
assert isinstance(subscription, MapAsyncIterable)
121121

122122
assert await anext(subscription) == ({"foo": "bar"}, None)

0 commit comments

Comments
 (0)