How can I quickly toggle between 'async' and 'non-async' code in PyCharm?

Hi, everyone.

I have an async def function,Within this async function, I extract some of the internal code into a separate new method.

which automatically creates an async def and adds an await when calling this function.

However, I want to quickly remove the async keyword because I want to move this function to a common package, and this function doesn't require any asynchronous operations.

Currently, I can only do this manually.

Perhaps PyCharm has a feature for quickly toggling between async and non-async functions, or it can automatically detect selected code that contains an await keyword and decide whether to automatically add the async keyword when extracting the code.


Please sign in to leave a comment.