mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 12:34:54 -04:00
Add missing type hints to synapse.util (#9982)
This commit is contained in:
parent
22a8838f62
commit
7adcb20fc0
9 changed files with 39 additions and 25 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue