Metadata-Version: 2.4
Name: ipython-smart-await
Version: 0.1.0
Summary: Auto-await coroutine results (calls, subscripts, item-assignment) in the IPython REPL.
Project-URL: Homepage, https://github.com/doronz88/ipython-smart-await
Project-URL: Repository, https://github.com/doronz88/ipython-smart-await
Project-URL: Issues, https://github.com/doronz88/ipython-smart-await/issues
Author-email: Doron Zarhi <doronz@kayhut.com>, Benjy Wiener <benjywiener@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: asyncio,await,extension,ipython,jupyter,repl
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: IPython
Classifier: Framework :: Jupyter
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: ipython>=8
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Description-Content-Type: text/markdown

# 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

```bash
pip install ipython-smart-await
```

## Usage

```python
%load_ext smart_await
```

Then, given some async API bound to `p`:

```python
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:

```python
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 async
  `setindex(key, value)` when the target exposes one, otherwise a normal item assignment — so
  dicts, lists, numpy arrays, etc. are unaffected.

## License

MIT
