Files

15 lines
381 B
Python
Raw Permalink Normal View History

2026-01-18 13:54:14 +03:00
from __future__ import annotations
from typing import Iterable, Iterator, Optional, TypeVar
T = TypeVar("T")
def progress(iterable: Iterable[T], *, total: Optional[int] = None, desc: str = "") -> Iterator[T]:
try:
from tqdm import tqdm # type: ignore
return iter(tqdm(iterable, total=total, desc=desc))
except Exception:
return iter(iterable)