Skip to main content

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

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tornado-async-transformer-0.2.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page