Adopt the modern-di integration kit#31
Merged
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's_DiMiddleware.consume_scopeandDependency/FromDIalready hand-roll. This swaps the hand-rolled internals for kit calls. No public-API change; zero test-file changes.Sixth 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 combines traits from two prior conversions: like Flask, it has exactly one connection/message type (
faststream.StreamMessage, broker-agnostic) sointegrations.bind()is used directly with noclassify_connection; unlike Flask,consume_scopewraps a single call site, so aContainerasync-context-manager block IS introduced. Like fastapi/litestar, FastStream has its own native DI seam (Depends), so there's no hand-rolled@injectto replace.consume_scopenow derives scope/context viaintegrations.bind(faststream_message_provider, msg)and opens the child container viaasync with ... as request_container:, nested with the existing syncwith self.context.scope(...):block. The deadimport modern_di(bare module) is removed.Dependency's field renamed tomarker: integrations.Marker[T_co];__call__delegates toself.marker.resolve(request_container).FromDIconstructsDependency(integrations.Marker(dependency)).architecture/dependency-injection.mdpromoted to describe the new internals.modern-difloor to>=2.28,<3.Test plan
just test-ci— 100% line coverage, all 5 tests passing, zero test-file changesjust lint-ci— ruff, ty, check-planning all clean