Changelog¶
All five distributions in this repository are versioned and released independently, so each gets its own section. Entries follow Keep a Changelog, and versions follow Semantic Versioning.
Update the relevant section before tagging a release — the tag and the package's pyproject.toml version must agree, and the release workflow enforces that.
pydepi¶
[0.1.1] — 2026-11-11¶
Fixed¶
add_singleton(T, instance=obj)inspectedT's constructor as ifdepiwere going to build it. That raisedMissingAnnotationErrorat registration for an unannotated constructor or aProtocolkey, andUnregisteredDependencyErrororInvalidLifetimeErroratbuild_provider()for the instance's own constructor dependencies. An instance registration now has no constructor parameters, the same as a factory registration.
[0.1.0] — 2026-09-02¶
First public release. The container itself has no dependencies.
Added¶
ServiceCollection/ServiceProvider/ServiceScopewith constructor injection resolved from type annotations.- Singleton, transient, and scoped lifetimes. Scopes are sync and async context managers;
__aexit__awaits async cleanup on scoped instances before disposing them. resolve_asyncand support for async factories.- Registration by interface (
add_singleton(ILogger, ConsoleLogger)), by instance, by factory, and in bulk viaregister_many. - Cycle detection by static analysis at
build_provider(), and lifetime validation that rejects a singleton depending on a scoped or transient service. depi.context: the ambient request scope —current_scope,get_current_scope,set_current_scope,reset_current_scope,use_scope. Framework adapters bind the same contextvar, so a scope opened by one is visible to all.depi.integration.BaseInjector: the contract every framework adapter builds on, including theparam_nameandautowireoptions.depi.exceptions: a typed hierarchy rooted atDepiError, split intoRegistrationError(startup — the container was described wrongly) andResolutionError(resolve time — it was asked for something it could not produce). Every class also derives from the type it previously raised, soexcept Exceptionandexcept RuntimeErrorhandlers keep working.ServiceProvider.is_registered/ServiceScope.is_registered, used by adapters to tell a service parameter from one the web framework will supply.- Autowire introspection evaluates annotations with
eval_str=True, so it works underfrom __future__ import annotations(PEP 563), where every annotation is a string. A parameter whose annotation cannot be evaluated — an unimportable forward reference, a builtin with no retrievable signature — is left for the framework to supply rather than raising at import time.
Fixed¶
ServiceScope.resolvehad no guard against async factories, so a scoped or transient async factory resolved through a scope returned an un-awaited coroutine instead of raising.ServiceProvider.resolvehad the guard; the scope path did not — and a scope is what every framework adapter resolves through, so this only surfaced inside a request, far from its cause.- The async-factory guard now closes the coroutine before raising. Abandoning it emitted
RuntimeWarning: coroutine ... was never awaitedon top of the exception, pointing at the wrong thing. - Cycle errors name the whole chain (
Order -> Invoice -> Customer -> Order) instead of only the type where detection happened. The message is trimmed to the cycle itself, so a class that merely depends on a loop is not blamed for it.
Notes¶
- A scope disposes what it owns. Exiting a scope calls
dispose()on the scoped instances it constructed. Transients are handed back untracked, and singletons belong to the provider, so neither is disposed by a scope. This differs from .NET, where a container disposes transients it created; depi does not hold that reference. Own a transient's cleanup yourself, or register it as scoped. Seedocs/concepts/disposal.md.
pydepi-flask¶
[0.1.0] — 2026-09-02¶
Added¶
FlaskInjector: a request-scopedServiceScopeopened inbefore_requestand disposed inteardown_request.injectdecorator, in two modes — passing the scope as a keyword argument (default), orautowire=Trueto resolve registered types by annotation while leaving URL arguments to Flask.param_nameto rename the injected argument, so an existingcontainer-style convention needs no fork.- Built with
functools.wraps, so it composes inside a decorator stack (route registration, auth, response handling) without the outer layers losing the view's identity.
Notes¶
- The scope and its contextvar token are stored on
flask.gso teardown restores exactly the context it replaced. Werkzeug reuses worker threads, and a contextvar set without a matching reset would leak into the next request served by that thread.
pydepi-quart¶
[0.1.0] — 2026-09-02¶
Added¶
QuartInjector: the async counterpart to the Flask adapter, with the same two injection modes andparam_nameoption.- Disposal goes through
ServiceScope.__aexit__, so scoped instances holding async resources get awaited cleanup beforedispose()runs.
pydepi-fastapi¶
[0.1.0] — 2026-09-02¶
Added¶
FastAPIInjector: scope management as a pure ASGI middleware, so the contextvar is set in the same context the endpoint coroutine runs in, and disposal happens after the response body is sent rather than when the handler returns.get_scope, for use asDepends(injector.get_scope). depi never touches endpoint signatures, so OpenAPI schemas stay clean.
Notes¶
autowire=Trueis rejected at construction, andinjectraises. FastAPI builds request parsing and the OpenAPI schema from the endpoint signature and raisesFastAPIErrorat decoration time for any annotation it cannot treat as a Pydantic field. Supporting either would require rewriting__signature__before FastAPI sees the endpoint, which is fragile across releases. The constraint is asserted by a test rather than assumed, so a future FastAPI that relaxes it will surface as a failure.
pydepi-django¶
[0.1.0] — 2026-09-02¶
Added¶
DjangoInjectorandDepiScopeMiddleware. Django builds middleware from a dotted path inMIDDLEWARE, so the injector registers itself at startup (fromAppConfig.ready()) rather than being constructed inline.- The middleware matches whatever
get_responseit is given, so both the sync and async request paths work without Django having to adapt between them. NoInjectorRegisteredError, raised with an explanation when the middleware runs before any injector registered itself.
Notes for anyone using this from git before 0.1.0¶
The package was restructured before its first release. If you were importing from the repository directly:
- The distribution is
pydepi, notdepi— that name belongs to an unrelated project on PyPI. The import name is stilldepi. depi.injectorsis removed. Framework adapters are now separate distributions with their own top-level modules:depi_flask,depi_quart,depi_fastapi,depi_django.DependencyInjector,FastAPIDependencyInjector,FlaskDependencyInjector,QuartDependencyInjectorand thecreate_*_injectorfactories are removed. They aliased a class that had no.injectand silently ignoredstrict, so nothing written against the documented API actually worked.- The
strictparameter and@di.injectsignature rewriting are gone. Provider injection is the default everywhere;autowire=Truereplaces the old non-strict behaviour on Flask, Quart and Django. FastAPI usesDepends. FlaskInjector.with_provideris nowFlaskInjector.inject, andsetup_flask/setup_fastapi/setup_quartare a singlesetup(app)per adapter.
Note
This page is included verbatim from
CHANGELOG.md
at the repository root. Release mechanics are in
RELEASING.md.
Known gaps and outstanding work are on the
Limitations page.