mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
fix formatting and some tests
This commit is contained in:
parent
c708532a8d
commit
ab9d902cc5
4 changed files with 8 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue