Auto-await coroutine results (calls, subscripts, item-assignment) in the IPython REPL.
Project description
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`
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()) and subscript reads (a[0]) 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 asyncsetindex(key, value)when the target exposes one, otherwise a normal item assignment — so dicts, lists, numpy arrays, etc. are unaffected.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipython_smart_await-0.1.0.tar.gz.
File metadata
- Download URL: ipython_smart_await-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba280c96d64ad78e57b8038027b6468c2ab2293932344bf12b723c265a9894df
|
|
| MD5 |
0794c4eed722705e6e81f4f0295cea4f
|
|
| BLAKE2b-256 |
ebe78cda89abc405abe45e4a406f6e44b6b77fd2546871cfcb80f753eea27119
|
Provenance
The following attestation bundles were made for ipython_smart_await-0.1.0.tar.gz:
Publisher:
release.yml on doronz88/ipython-smart-await
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipython_smart_await-0.1.0.tar.gz -
Subject digest:
ba280c96d64ad78e57b8038027b6468c2ab2293932344bf12b723c265a9894df - Sigstore transparency entry: 1928977703
- Sigstore integration time:
-
Permalink:
doronz88/ipython-smart-await@ffd08ec6b3b26aefd7e5865720134078022994b0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/doronz88
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffd08ec6b3b26aefd7e5865720134078022994b0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ipython_smart_await-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipython_smart_await-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
916fc2b82d8e604a9cc349fdb7f0029fbf1e50c4d334dc992c2e772bd4d94425
|
|
| MD5 |
4e7f9a5c25d6774fc412739094330354
|
|
| BLAKE2b-256 |
4ee9eb3b099ce5163854794cef5f828f5d7bbf235de51fe52b0c08f2748ae142
|
Provenance
The following attestation bundles were made for ipython_smart_await-0.1.0-py3-none-any.whl:
Publisher:
release.yml on doronz88/ipython-smart-await
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipython_smart_await-0.1.0-py3-none-any.whl -
Subject digest:
916fc2b82d8e604a9cc349fdb7f0029fbf1e50c4d334dc992c2e772bd4d94425 - Sigstore transparency entry: 1928977804
- Sigstore integration time:
-
Permalink:
doronz88/ipython-smart-await@ffd08ec6b3b26aefd7e5865720134078022994b0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/doronz88
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffd08ec6b3b26aefd7e5865720134078022994b0 -
Trigger Event:
release
-
Statement type: