Adopt the modern-di integration kit#3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
modern-di2.28.0 shippedmodern_di.integrations— framework-agnostic primitives that formalize what this package'sbuild_di_containerandDependency/FromDIalready hand-roll. This swaps the hand-rolled internals for kit calls. No public-API change; zero test-file changes.Eleventh of 13 planned adapter conversions (after starlette 2.2.0, fastapi 2.10.0, litestar 2.13.0, aiohttp 2.2.0, flask 2.1.0, faststream 2.10.0, typer 2.3.0, grpc 2.1.0, celery 2.1.0, arq 2.1.0).
taskiq is a native-DI adapter (uses taskiq's own
TaskiqDepends), with a single connection provider (taskiq_message_provider, bindingtaskiq.TaskiqMessage) — so, like grpc, it usesintegrations.bind()directly with noclassify_connectionand noif match else Nonefallback (unlike fastapi/litestar, which have two providers). And like fastapi/litestar/faststream,Dependency's field holds anintegrations.MarkerwhileFromDIkeeps wrapping taskiq's ownTaskiqDepends.build_di_containerderives scope/context viaintegrations.bind(taskiq_message_provider, context.message)and opens the child viaasync with ... as container: yield container, replacing the manualtry/finally: close_async().Dependency's field renamed tomarker: integrations.Marker[T_co];__call__delegates toself.marker.resolve(request_container).FromDIconstructsDependency(integrations.Marker(dependency)).setup_di,fetch_di_container, and the worker-event lifecycle wiring are untouched.architecture/dependency-injection.mdpromoted to describe the new internals.modern-difloor to>=2.28,<3.Test plan
just test-ci— 100% line coverage, all 7 tests passing (usesInMemoryBroker, no external service), zero test-file changesjust lint-ci— ruff, ty, check-planning all cleanasync withstructure preserves the original try/finally's close-timing on both the normal and task-error paths)