Skip to main content

ipython-smart-await

Auto-await coroutine results in the IPython REPL — drive a pure-async API without typing await everywhere.

When loaded, the extension rewrites each input cell so that expressions which evaluate to a coroutine are awaited automatically on IPython's loop runner.

Install

pip install ipython-smart-await

Usage

%load_ext smart_await

Then, given some async API bound to p:

p.get_pid()          # -> awaited automatically (no `await` needed)
a[0]                 # -> awaited if `a.__getitem__` returns a coroutine
a[0] = 7             # -> routed to `a.setindex(0, 7)` (awaited) when `a` has an async `setindex`
proxy.length         # -> awaited if attribute access returns a coroutine (dynamic proxies)

Opting out

Wrap a call in ...( ) to get the raw, un-awaited value:

coro = ...(p.get_pid())   # `coro` is the coroutine itself

Cells that already use await / async constructs are left untouched.

How it works

The extension installs an ast transformer (an IPython AST transformer) that wraps:

  • calls (foo()), subscript reads (a[0]), and attribute reads (a.b) in a helper that awaits the result only if it is a coroutine (non-coroutines pass through unchanged);
  • single-target subscript assignment (a[0] = v) into a call that routes to an async setindex(key, value) when the target exposes one, otherwise a normal item assignment — so dicts, lists, numpy arrays, etc. are unaffected.

License

MIT

Download files

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

Source Distribution

ipython_smart_await-0.3.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipython_smart_await-0.3.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file ipython_smart_await-0.3.0.tar.gz.

File metadata

  • Download URL: ipython_smart_await-0.3.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ipython_smart_await-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b5fbe492f700aa6c6696a2791b4b0aaa82d0c98813ef837ae3c1221a4c23f147
MD5 2009745ded730a8bd859e6b8cb930e6d
BLAKE2b-256 923d163c633d7dcee44251066137b34902f1686582ec3c230d29ed325505c311

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipython_smart_await-0.3.0.tar.gz:

Publisher: release.yml on doronz88/ipython-smart-await

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipython_smart_await-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ipython_smart_await-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfaf6ae7016e6f1c51631cd1a2b02338b5e9c9a4b969944ba87fb2dbbd05343f
MD5 dfeda533db356b2d5273f23890fc88be
BLAKE2b-256 c22606740ce08af480038e650f25a93f8071f84936f581d85947e74720b7682d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipython_smart_await-0.3.0-py3-none-any.whl:

Publisher: release.yml on doronz88/ipython-smart-await

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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