Loading muffin/utils.py +5 −1 Original line number Diff line number Diff line import itertools from typing import TypeVar, Callable from collections.abc import Iterable, Iterator T = TypeVar("T") S = TypeVar("S") def group_by(iterable, key): def group_by(iterable: Iterable[T], key: Callable[[T], S]) -> Iterator[tuple[S, Iterator[T]]]: return itertools.groupby(sorted(iterable, key=key), key) Loading
muffin/utils.py +5 −1 Original line number Diff line number Diff line import itertools from typing import TypeVar, Callable from collections.abc import Iterable, Iterator T = TypeVar("T") S = TypeVar("S") def group_by(iterable, key): def group_by(iterable: Iterable[T], key: Callable[[T], S]) -> Iterator[tuple[S, Iterator[T]]]: return itertools.groupby(sorted(iterable, key=key), key)