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.2.0.tar.gz (6.2 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.2.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ipython_smart_await-0.2.0.tar.gz
  • Upload date:
  • Size: 6.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 6f8f157586824d7d1fcfbbd6d177c13c3f417de80a5c98317e5ab856a54c5c44
MD5 e6d3454b4075c6ea072b4f56ad60c664
BLAKE2b-256 7b05139b3f7c63f3b11ff97adf25bd206dbc9861bd88bbff174033b0f76f771a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipython_smart_await-0.2.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ipython_smart_await-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe74b319417f6679b10711a408fe1eeda5f11d2bdf72b85c14176224f697873
MD5 6b796b7c8d4a63eab4edeb8522f85400
BLAKE2b-256 bfdc9a99121c4ac741cebac6765e00e168d6ae1946fcd62f057275904c54e0af

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipython_smart_await-0.2.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