Magical function composition
Project description
incant🪄: a little magic for your functions
incant is a Python open source library for composing and calling functions. Going by the old, humorous adage that dependency injection is simply passing arguments to functions, incant is a toolkit that is well suited to that use case.
incant will help you with:
- all kinds of dependency injection scenarios
- adapting interfaces of third-party libraries to make them more flexible
- generically wrapping functions and coroutines for instrumentation
- creating signature-altering decorators
- calling functions and coroutines with unknown signatures safely
- ... and much more!
For example:
from incant import Incanter
incanter = Incanter()
@incanter.register_by_name
def now() -> float:
"""
Return the current timestamp.
We can replace this for testing later.
"""
from time import time
return time()
def my_function(now: float) -> None:
print(f"The time now is {now}")
incanter.compose_and_call(my_function)
incant has a fully type-annotated interface for use with Mypy and Pyright. incant works by generating Python code at runtime, and is extremely efficient. (incant is the fastest Python dependency injection framework we're aware of.)
If you're familiar with pytest, incant dependency factories are roughly equivalent to pytest fixtures.
Project Information
License
incant is written by Tin Tvrtković and distributed under the terms of the Apache-2.0 license.
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 incant-25.1.0.tar.gz.
File metadata
- Download URL: incant-25.1.0.tar.gz
- Upload date:
- Size: 538.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3624bcd81e96145921b008d4a0111779bb9fc8e15052ae6307cf6ec7343021c3
|
|
| MD5 |
ca50cd2b67575687f0718b8bf141a2fe
|
|
| BLAKE2b-256 |
4afd0b842adae881846e73770dba3ce55251cb98a893ccd9fb80b430d4256d5c
|
Provenance
The following attestation bundles were made for incant-25.1.0.tar.gz:
Publisher:
pypi-package.yml on Tinche/incant
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
incant-25.1.0.tar.gz -
Subject digest:
3624bcd81e96145921b008d4a0111779bb9fc8e15052ae6307cf6ec7343021c3 - Sigstore transparency entry: 219782871
- Sigstore integration time:
-
Permalink:
Tinche/incant@f73fd3f84747da4fa1937730f9ad5dbe7cebe43c -
Branch / Tag:
refs/tags/v25.1.0 - Owner: https://github.com/Tinche
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-package.yml@f73fd3f84747da4fa1937730f9ad5dbe7cebe43c -
Trigger Event:
release
-
Statement type:
File details
Details for the file incant-25.1.0-py3-none-any.whl.
File metadata
- Download URL: incant-25.1.0-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32418e346351eaa525350ee0953f6d02d710cd83c54e872f7de7cd64fecb343
|
|
| MD5 |
eef8bc7d2fc2c886dbf5c24ba6c7aca8
|
|
| BLAKE2b-256 |
aaf9bb5a0d05ffc5eea4546696e9b3113fbda3b64838fda52a162b5ec9451f7d
|
Provenance
The following attestation bundles were made for incant-25.1.0-py3-none-any.whl:
Publisher:
pypi-package.yml on Tinche/incant
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
incant-25.1.0-py3-none-any.whl -
Subject digest:
f32418e346351eaa525350ee0953f6d02d710cd83c54e872f7de7cd64fecb343 - Sigstore transparency entry: 219782873
- Sigstore integration time:
-
Permalink:
Tinche/incant@f73fd3f84747da4fa1937730f9ad5dbe7cebe43c -
Branch / Tag:
refs/tags/v25.1.0 - Owner: https://github.com/Tinche
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-package.yml@f73fd3f84747da4fa1937730f9ad5dbe7cebe43c -
Trigger Event:
release
-
Statement type: