A libcst transformer for updating tornado @gen.coroutine syntax to python3.5+ native async/await.
You can either:
- Add
tornado_async_transformer.TornadoAsyncTransformer
to your existing libcst codemod. - Or run
python -m tornado_async_transformer.tool my_project/
from the commandline.
"""
A simple coroutine.
"""
from tornado import gen
-@gen.coroutine
-def call_api():
- response = yield fetch()
+async def call_api():
+ response = await fetch()
if response.status != 200:
raise BadStatusError()
- raise gen.Return(response.data)
+ return response.data