Releases: modern-python/modern-di-taskiq
Release list
2.1.0
modern-di-taskiq 2.1.0 — adopt the modern-di integration kit
Maintenance release. No public API change — FromDI, setup_di,
fetch_di_container, and taskiq_message_provider keep their signatures
and behavior. Swaps this package's hand-rolled connection-context derivation
and marker resolution for the shared primitives in
modern_di.integrations,
shipped in
modern-di 2.28.0.
Eleventh of 13 planned adapter conversions across the modern-di ecosystem
(after
modern-di-starlette 2.2.0,
modern-di-fastapi 2.10.0,
modern-di-litestar 2.13.0,
modern-di-aiohttp 2.2.0,
modern-di-flask 2.1.0,
modern-di-faststream 2.10.0,
modern-di-typer 2.3.0,
modern-di-grpc 2.1.0,
modern-di-celery 2.1.0,
and
modern-di-arq 2.1.0).
taskiq is a native-DI adapter (uses taskiq's own TaskiqDepends) with a
single connection provider, so — like grpc — it uses bind() directly with
no classify_connection.
Internal refactors
build_di_containernow derives scope/context via
integrations.bind(taskiq_message_provider, context.message), and opens
the per-task child viaasync with ... as container: yield container—
replacing the manualtry/finally: await container.close_async(). taskiq
has a single connection provider, so there's noclassify_connection
dispatch (nothing to dispatch across).Dependency's field is renamed from a rawdependencyto
marker: integrations.Marker[T_co];__call__delegates to
self.marker.resolve(request_container).FromDInow constructs
Dependency(integrations.Marker(dependency))— its own signature
(dependency, *, use_cache) is unchanged, and it still wraps taskiq's own
TaskiqDepends.- Like
modern-di-fastapi/modern-di-litestar/modern-di-faststream, this
package is a native-DI adapter: no hand-rolled@injectdecorator, no
parse_markers/resolve_markersusage, and no imports become dead. setup_di,fetch_di_container, and the
WORKER_STARTUP/WORKER_SHUTDOWNroot-lifecycle wiring are untouched.architecture/dependency-injection.md's "Per-task scope" and "Resolution"
sections promoted to describe the new internals.
Packaging
- Bumps the
modern-difloor to>=2.28,<3.
Downstream
No action needed — the public API (FromDI, setup_di,
fetch_di_container, taskiq_message_provider) is unchanged. Upgrading
only requires modern-di>=2.28.0.
Internals
- 100% line coverage;
ruff,tyclean across Python 3.10–3.14. Tests use
taskiq.InMemoryBroker(no external broker). - Built via
subagent-driven-development: 5 planned tasks, each with an
independent spec+quality review; a whole-branch review before merge that
traced the async-generator-inside-async withstructure's close-timing
against the originaltry/finallyon both the normal and task-error
paths.
2.0.0
modern-di-taskiq 2.0.0 — first release
First release of the taskiq integration for modern-di. It wires a
modern-di container into a
taskiq broker and resolves dependencies into
task handlers, scoped per task. The version starts at 2.0.0 to track the
modern-di 2.x ecosystem alongside the other official integrations.
taskiq has its own dependency-injection system (TaskiqDepends), so this
integration follows modern-di's native-DI generator-dependency path:
FromDI returns a TaskiqDepends marker, and a generator dependency owns the
per-task container lifecycle.
Feature
setup_di(broker, container). Stashes the root container on the broker
(broker.state, under a named constant, read back with
fetch_di_container(broker)), registers the connection provider, and wires
the container's lifecycle to the broker's worker events — reopening it on
WORKER_STARTUP(so a worker restart works) and closing it on
WORKER_SHUTDOWN. Returns the container.- Per-task child containers. A generator dependency opens one
Scope.REQUESTchild container per task, seeded with the current
taskiq.TaskiqMessageas context, and closes it when the task finishes —
including when the task raises. taskiq resolves the generator once per task,
so everyFromDIparameter in a task shares the same child. FromDI. Mark a task parameter with
Annotated[T, FromDI(provider_or_type)]; it resolves from the task's child
container.FromDIaccepts a provider reference or a bare type, dispatching
throughContainer.resolve_dependency(so overrides, caching, and
did-you-mean suggestions are inherited).taskiq_message_provider. AContextProviderbinding
taskiq.TaskiqMessageatScope.REQUEST, so the current message is
resolvable inside DI.
Packaging
- Requires
taskiq>=0.11,<0.13andmodern-di>=2.25,<3; Python 3.10–3.14. - Ships
py.typed; zero runtime dependencies beyond taskiq and modern-di. - Resolution stays synchronous by design; only the per-task container builder
and finalizers are async.
Downstream
No action needed — this is a new package.
Internals
- 100% line coverage;
ruff,ty, andeof-fixerclean across Python
3.10–3.14. - Uses the portable planning convention (
planning/) with anarchitecture/
truth home; releases are tag-driven.