Python/Eliminate Async Io

/icons/calendar.svg

Last update

Sep 5, 2024

This codemod transforms an asynchronous Python code into synchronous code by removing or modifying specific async and await patterns.

This codemod eliminates import asyncio statements, removes await expressions, unwraps asyncio.run() calls, and converts async def function definitions to synchronous def function definitions. This can be useful in environments where async functionality is not supported or not required.

Examples

Before

import asyncio
async def main():
somecall(1, 5)
asyncio.run(main())

After

def main():
somecall(1, 5)
main()

Before

def main():
await someothercall()

After

def main():
someothercall()

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now