Skip to content

libcst transformer that replaces tornado's legacy @gen.coroutine syntax with python3.5+ native async/await

License

Notifications You must be signed in to change notification settings

zhammer/tornado-async-transformer

 
 

Repository files navigation

Tornado Async Transformer

A libcst transformer for updating tornado @gen.coroutine syntax to python3.5+ native async/await.

Check out the demo.

Usage

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.

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

About

libcst transformer that replaces tornado's legacy @gen.coroutine syntax with python3.5+ native async/await

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 93.4%
  • JavaScript 3.5%
  • HTML 2.4%
  • CSS 0.7%