summary refs log tree commit diff
path: root/synapse/util/iterutils.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-05-25 10:23:00 +0100
committerErik Johnston <erik@matrix.org>2021-05-25 10:23:00 +0100
commit2d83d1906161ab7794ee41265ff49f3b3ff1c591 (patch)
tree8b7718387857071ed8c93bd75562eb76ca9b41c0 /synapse/util/iterutils.py
parentMerge remote-tracking branch 'origin/develop' into matrix-org-hotfixes (diff)
parentRun complement with Synapse workers manually. (#10039) (diff)
downloadsynapse-2d83d1906161ab7794ee41265ff49f3b3ff1c591.tar.xz
Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/util/iterutils.py')
-rw-r--r--synapse/util/iterutils.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/synapse/util/iterutils.py b/synapse/util/iterutils.py

index abfdc29832..886afa9d19 100644 --- a/synapse/util/iterutils.py +++ b/synapse/util/iterutils.py
@@ -30,12 +30,12 @@ from typing import ( T = TypeVar("T") -def batch_iter(iterable: Iterable[T], size: int) -> Iterator[Tuple[T]]: +def batch_iter(iterable: Iterable[T], size: int) -> Iterator[Tuple[T, ...]]: """batch an iterable up into tuples with a maximum size Args: - iterable (iterable): the iterable to slice - size (int): the maximum batch size + iterable: the iterable to slice + size: the maximum batch size Returns: an iterator over the chunks @@ -46,10 +46,7 @@ def batch_iter(iterable: Iterable[T], size: int) -> Iterator[Tuple[T]]: return iter(lambda: tuple(islice(sourceiter, size)), ()) -ISeq = TypeVar("ISeq", bound=Sequence, covariant=True) - - -def chunk_seq(iseq: ISeq, maxlen: int) -> Iterable[ISeq]: +def chunk_seq(iseq: Sequence[T], maxlen: int) -> Iterable[Sequence[T]]: """Split the given sequence into chunks of the given size The last chunk may be shorter than the given size.