Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions stdlib/asyncio/tasks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ else:

_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_sai = TypeVar("_T_sai") # invariant, for _SyncAndAsyncIterator Protocol
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use _T?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! _T is already invariant — no need for a separate _T_sai. Replaced all uses with _T. Thanks! 🙏

_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
Expand All @@ -88,9 +89,9 @@ ALL_COMPLETED: Final = concurrent.futures.ALL_COMPLETED

if sys.version_info >= (3, 13):
@type_check_only
class _SyncAndAsyncIterator(Iterator[_T_co], AsyncIterator[_T_co], Protocol[_T_co]): ...
class _SyncAndAsyncIterator(Iterator[Coroutine[Any, Any, _T_sai]], AsyncIterator[Future[_T_sai]], Protocol[_T_sai]): ...

def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[Future[_T]]: ...
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[_T]: ...

elif sys.version_info >= (3, 10):
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...
Expand Down
Loading