after years of refusing to use type variables in Python because the syntax was just horrendous, i've learned that in Python 3.13 they've added syntax for it that's just normal! check this out:
from typing import overload
from collections.abc import Iterator, Generator, AsyncIterator, AsyncGenerator
@overload
def with_progress[T](iter: Iterator[T]) -> Generator[T]: ...
@overload
def with_progress[T](iter: AsyncIterator[T]) -> AsyncGenerator[T]: ...
I'm starting to like Python type annotations (separately from Python typecheckers, which have a much more spotty usability record outside of pyright)