Skip to content

Commit d8293c8

Browse files
sentinel is None
1 parent 702b770 commit d8293c8

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

asyncstdlib/itertools.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ async def cycle(iterable: AnyIterable[T]) -> AsyncIterator[T]:
6464
yield item
6565

6666

67-
__ACCUMULATE_SENTINEL = Sentinel("<no default>")
68-
69-
7067
async def add(x: ADD, y: ADD) -> ADD:
7168
"""The default reduction of :py:func:`~.accumulate`"""
7269
return x + y
@@ -78,7 +75,7 @@ async def accumulate(
7875
Callable[[Any, Any], Any], Callable[[Any, Any], Awaitable[Any]]
7976
] = add,
8077
*,
81-
initial: Any = __ACCUMULATE_SENTINEL,
78+
initial: Any = None,
8279
) -> AsyncIterator[Any]:
8380
"""
8481
An :term:`asynchronous iterator` on the running reduction of ``iterable``
@@ -105,11 +102,7 @@ async def accumulate(iterable, function, *, initial):
105102
"""
106103
async with ScopedIter(iterable) as item_iter:
107104
try:
108-
value = (
109-
initial
110-
if initial is not __ACCUMULATE_SENTINEL
111-
else await anext(item_iter)
112-
)
105+
value = initial if initial is not None else await anext(item_iter)
113106
except StopAsyncIteration:
114107
raise TypeError(
115108
"accumulate() of empty sequence with no initial value"

0 commit comments

Comments
 (0)