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)

0

If you have a fediverse account, you can quote this note from your own instance. Search https://social.treehouse.systems/users/whitequark/statuses/116136999254071067 on your instance and quote it. (Note that quoting is not supported in Mastodon.)