Tornado Async Transformer
A libcst transformer for updating tornado @gen.coroutine syntax to python3.5+ native async/await.
Read the article about this tool.
Usage
You can either:
- Add
tornado_async_transformer.TornadoAsyncTransformer
to your existing libcst codemod or just install the packagepython3 setup.py install
- Or run
python -m tornado_async_transformer.tool my_project/
from the commandline.
Example
"""
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