uncalled-for
Async dependency injection for Python functions.
Declare what your function needs as parameter defaults. They show up resolved when the function runs. No ceremony, no container, no configuration.
from uncalled_for import Depends
async def get_db():
db = await connect()
try:
yield db
finally:
await db.close()
async def handle_request(db: Connection = Depends(get_db)):
await db.execute("SELECT 1")
Features
- Zero dependencies — standard library only
- Async-native — built on
AsyncExitStackandContextVar - Context manager lifecycle — sync and async generators get proper cleanup
- Nested dependencies — dependencies can depend on other dependencies
- Caching — each dependency resolves once per call, even if referenced multiple times
- Call arguments — a factory can reference the arguments of the call it serves
Call arguments
A factory sometimes needs a value from the call itself, not from another
dependency. CallArgument declares that reference:
from uncalled_for import CallArgument, Depends
def load_user(user_id: str = CallArgument()) -> User:
return users[user_id]
async def handle_request(
user_id: str,
user: User = Depends(load_user),
):
...
The bare form takes the name of the parameter it is declared on.
CallArgument("name") names a different parameter of the outer function. The
reference sees the same value the outer function receives, whether the caller
passed it or another dependency on the outer signature produced it.
CallArgument(optional=True) yields None when the outer function has no
such argument. References that form a cycle raise CycleError.
Bindings
Depends accepts keyword bindings, so you can wire up an ordinary function
without changing it:
async def handle_request(
user_id: str,
user: User = Depends(load_user, user_id=CallArgument("user_id")),
):
...
A binding that is a Dependency, such as CallArgument(...) or another
Depends(...), resolves first and the factory receives its value. Any other
value passes through as it is. A binding replaces the factory parameter's own
default, which is then never resolved. Two dependencies on the same factory
share one cached result only when their bindings match.
Install
pip install uncalled-for
Metadata
Release files for uncalled-for 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| uncalled_for-0.4.1.tar.gz | 57.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uncalled_for-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 71.9 kB
Release files / uncalled_for-0.4.1.tar.gz
| Download URL | uncalled_for-0.4.1.tar.gz |
|---|---|
| Size | 57.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6412b19d1b1e7d431981fee01f8b47be7802f48328a48cbe9603acee757ec553
|
|
BLAKE2b-256 checksum How to use checksums |
6c544651e4c5fe84300f8e03c0390aaad41bcb9c7b81d7783542a3ee690b40ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / uncalled_for-0.4.1-py3-none-any.whl
| Download URL | uncalled_for-0.4.1-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b611b38879d9fe5088297e7bb28f2ddd12d2d73dad933d93da107fb63eb4058e
|
|
BLAKE2b-256 checksum How to use checksums |
bfa6ba763e3812e572de7291676c3a41adfac1ef1209a6acda6bae055970f127
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency log