incant 23.2.0

Creator: bradpython12

Last updated:

Add to Cart

Description:

incant 23.2.0

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

PyPI
Source Code
Documentation
Changelog

License
incant is written by Tin Tvrtković and distributed under the terms of the Apache-2.0 license.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.