Error-prone naming: asyncio.timeout vs asyncio.Timeout

Both can be used in the same construct:

async with asyncio.timeout(99): await ...
async with asyncio.Timeout(99): await ...

But the latter has a different meaning and is probably not what you want. There is no error and no pylint warning. I also made that mistake and confused those two. I don’t know what possibilities are there for a fix, but I think it is quite unfortunate that currently it is so easy to make such mistake.

9 Likes

I don’t think asyncio.Timeout is intended to be used directly? That means we could at least start the deprecation process on use of it by that name for eventual cleanup with it renamed to something less conflicting. I’d start that by filing an issue.

1 Like