from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from typing import Any, overload

__all__ = ("countby", "partitionby")

@overload
def countby[T, K](key: Callable[[T], K], seq: Iterable[T]) -> dict[K, int]: ...
@overload
def countby[V](key: Any, seq: Iterable[Sequence[V] | Mapping[Any, V]]) -> dict[V, int]: ...
def countby[T, K, V]( key: Callable[[T], K] | Any, seq: Iterable[T] | Iterable[Sequence[V] | Mapping[Any, V]] ) -> dict[K, int] | dict[V, int]: ...

class partitionby[T](Iterator[tuple[T, ...]]):
	def __init__(self, func: Callable[[T], Any], seq: Iterable[T]) -> None: ...
	def __iter__(self) -> partitionby[T]: ...
	def __next__(self) -> tuple[T, ...]: ...
