Skip to content

asyncio.staggered has incorrect type hints #114281

Closed
@sobolevn

Description

@sobolevn

Bug report

Correct ones: https://github.com/python/typeshed/blob/8885cc870cc1089cba30a6ac6d4ea1e32c83cedb/stdlib/asyncio/staggered.pyi

There are several major problems:

  1. loop: events.AbstractEventLoop = None, relies on very old mypy behaviour
  2. coro_fns: typing.Iterable[typing.Callable[[], typing.Awaitable]] does not have type var for Awaitable, which is very hard to read: reader has to infer this type variable themself

This is a problem if people are using runtime type-checkers that will use __annotations__ from this function and not typeshed definitions.

Basically, we don't use annotations in the stdlib, but when we do: it should be correct.

I propose fixing it and even upgrading some other stuff:

  1. It is a simple quality of life improvement
  2. It only uses simple types
  3. All python versions for backports are supported
  4. It should not be edited again in the recent future

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions