-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
Description
asyncio.Timeout is exported by asyncio.__all__ and thus available when doing from asyncio import *. It is documented as the return type of asyncio.timeout[at]. In #141401, it was suggested to rename that class to avoid possible typos when writing asyncio.timeout However, I pointed several issues with that approach:
- We cannot change a public API without a deprecation period.
- Making it deprecated is painful. We need to support
Timeoutbeing used in type annotations, so the warning should be emitted at construction time. However we do not want that warning to be emitted when usingasyncio.timeout[at]. Alternatively we could have two different classes or make other hacks, but AFAICT, this would rather seem like an ugly hack that I would like to avoid.
IMOM, the best course of action is:
- Improve the docs to indicate that the class exists, the interface exists, but that it should not be instantiated directly. It can however be used in type annotations or users could decide to subclass the class to provide an improved interface for their own needs.
- Add a rule to linters so that any usage of
async with asyncio.Timeout(...)is flagged and that the user likely wantedasync with asyncio.timeoutinstead. It's not our call to make but changing the docs first would give more weight to that decision on their side.
Metadata
Metadata
Assignees
Labels
Projects
Status
Todo
Status
Todo