Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/libcst/_parser/custom_itertools.py: 67%
6 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:43 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:43 +0000
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2#
3# This source code is licensed under the MIT license found in the
4# LICENSE file in the root directory of this source tree.
6from itertools import zip_longest
7from typing import Iterable, Iterator, TypeVar
9_T = TypeVar("_T")
12# https://docs.python.org/3/library/itertools.html#itertools-recipes
13def grouper(iterable: Iterable[_T], n: int, fillvalue: _T = None) -> Iterator[_T]:
14 "Collect data into fixed-length chunks or blocks"
15 # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
16 args = [iter(iterable)] * n
17 return zip_longest(*args, fillvalue=fillvalue)