Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions modern_di_faststream/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def setup_di(
msg = "Broker must be defined to setup DI"
raise RuntimeError(msg)

container.providers_registry.add_providers(faststream_message_provider)
container.add_providers(faststream_message_provider)
app.context.set_global(_ROOT_CONTAINER_KEY, container)
# FastStream's lifecycle is callback-based, so the root container can't be
# wrapped in ``async with``. Reopen it on startup (before the broker consumes)
Expand All @@ -87,9 +87,7 @@ class Dependency(typing.Generic[T_co]):

async def __call__(self, context: faststream.ContextRepo) -> T_co:
request_container: Container = context.get(_REQUEST_CONTAINER_KEY)
if isinstance(self.dependency, providers.AbstractProvider):
return request_container.resolve_provider(self.dependency)
return request_container.resolve(dependency_type=self.dependency)
return request_container.resolve_dependency(self.dependency)


def FromDI( # noqa: N802
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"Typing :: Typed",
"Topic :: Software Development :: Libraries",
]
dependencies = ["faststream>=0.7,<0.8", "modern-di>=2.19.0,<3"]
dependencies = ["faststream>=0.7,<0.8", "modern-di>=2.25,<3"]
version = "0"

[project.urls]
Expand Down
Loading