fix formatting and some tests

This commit is contained in:
jgcodes2020 2024-12-24 10:41:35 -05:00
parent c708532a8d
commit ab9d902cc5
4 changed files with 8 additions and 7 deletions

View file

@ -156,6 +156,7 @@ def unescape_quote(string: str) -> str:
return result
def iter_batched(iterable, n, *, strict=False):
"""
Replacement for `itertools.batched()` since the testing infrastructure
@ -163,9 +164,9 @@ def iter_batched(iterable, n, *, strict=False):
"""
# batched('ABCDEFG', 3) → ABC DEF G
if n < 1:
raise ValueError('n must be at least one')
raise ValueError("n must be at least one")
iterator = iter(iterable)
while batch := tuple(itertools.islice(iterator, n)):
if strict and len(batch) != n:
raise ValueError('batched(): incomplete batch')
yield batch
raise ValueError("batched(): incomplete batch")
yield batch