Import async_timeout only on Python before 3.11
ProprietaryFor a project that still supports Python before 3.11, replace an import of async_timeout with one chosen by sys.version_info: asyncio.timeout from 3.11, where async-timeout need not be installed, and async_timeout before it. import async_timeout becomes names the calls use, asyncio_timeout and asyncio_timeout_at, and from async_timeout import timeout keeps its name. A file is fenced only where every use is an async with entering the timeout, whose bound name, if any, is never read, since the members of the two timeouts differ. A synchronous with directly in an async def becomes async with, a pure loop= argument is dropped, and a value passed by keyword is passed positionally. Left untouched: a file with any other use, an import inside a function or already under a guard, several imports of the module, and a call holding a comment.
org. openrewrite. python. migrate. FenceAsyncTimeoutImportsmod run . --recipe= org. openrewrite. python. migrate. FenceAsyncTimeoutImportsInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.