Versions follow CalVer with a best-effort backwards-compatibility policy.
The first number of the version is the year. The second number is incremented with each release, starting at 1 for each year. The third number is when we need to start branches for older releases (only for emergencies).
- Fix a code generation issue with context managers, and generate prettier code (for inspection). (#15)
- Python 3.12 support. (#16)
- Use Ruff for import sorting.
Incanter.(a)invoke()
has been renamed to {meth}Incanter.(a)compose_and_call() <incant.Incanter.compose_and_call>
for clarity.Incanter.(a)invoke()
is still present as an alias for backwards compatibility.Incanter.prepare()
has been renamed to {meth}Incanter.compose() <incant.Incanter.compose>
for clarity.Incanter.prepare()
is still present as an alias for backwards compatibility.- Introduce {meth}
Incanter.adapt <incant.Incanter.adapt>
. - Dependency factories of constants (
lambda: 1
) are now folded to just the constants in the generated source code, avoiding unnecessary function calls. - {meth}
Incanter.register_by_type() <incant.Incanter.register_by_type>
now also triggers on type equality (in addition to subclasses). This makes it usable with types such asCallable
. - Python 3.12 support.
- Fix dependencies satisfying themselves.
- Switch to PDM.
- Fix parameter dependencies using the new union syntax.
- The documentation is now generated by Sphinx and available at incant.threeofwands.com.
- Fix an optimization for explicitly sync functions.
- Fix an issue incanting unnecessary positional arguments.
- Support
__future__
annotations (PEP 563) on Python 3.10+.
- Fix an issue when wrapping a sync function with an async one.
- Python 3.11 support.
- Fix
unbound local error
while generating code. (#4) - Avoid using local variables in generated code when possible.
- When
incant.prepare
cannot do anything for a function, return the original function for efficiency.
- Breaking change: due to limitations in autodetecting context managers (both sync and async), context manager dependencies must be explicitly registered by passing
is_context_manager="sync"
(orasync
) to the registration functions. - Injection can be customized on a per-parameter basis by annotating a parameter with
Annotated[type, incant.Override(...)]
. - Implement support for forced dependencies.
- Sync context managers may now be dependencies.
incanter.a/incant()
now handles unfulfilled parameters with defaults properly.- Switched to CalVer.
- Properly set the return type annotation when preparing a function.
- A hook override can now force a dependency to be promoted to a parameter (instead of being satisfied) by setting
Hook.factory
toNone
. - Parameters with defaults are now supported for
incanter.prepare
andincanter.a/invoke
. incanter.a/incant
no longer usesinvoke
under the hood, to allow greater customization. Previous behavior can be replicated byincant(prepare(fn))
.- Optional arguments of dependencies can now be propagated to final function arguments. Keyword-only arguments of dependencies are still filtered out.
- Introduce
incanter.prepare
, and makeincanter.a/invoke
use it.prepare
just generates the prepared injection wrapper for a function and returns it, without executing it. - Remove
incanter.parameters
, since it's now equivalent toinspect.signature(incanter.prepare(fn)).parameters
. - Add the ability to pass hook overrides to
incanter.prepare
, and introduce theincanter.Hook
class to make it more usable.
- Initial release.