diff --git a/modern_di_faststream/main.py b/modern_di_faststream/main.py index a6ad2a9..017d827 100644 --- a/modern_di_faststream/main.py +++ b/modern_di_faststream/main.py @@ -1,7 +1,6 @@ import dataclasses import typing from collections.abc import Awaitable, Callable -from importlib.metadata import version import faststream import modern_di @@ -17,10 +16,6 @@ faststream_message_provider = providers.ContextProvider(scope=Scope.REQUEST, context_type=faststream.StreamMessage) -_major, _minor, *_ = version("faststream").split(".") -_OLD_MIDDLEWARES = int(_major) == 0 and int(_minor) < 6 # noqa: PLR2004 - - class _DIMiddlewareFactory: __slots__ = ("di_container",) @@ -53,17 +48,9 @@ async def consume_scope( finally: await request_container.close_async() - if _OLD_MIDDLEWARES: # pragma: no cover - - @property - def faststream_context(self) -> faststream.ContextRepo: - return typing.cast(faststream.ContextRepo, faststream.context) # ty: ignore[possibly-missing-submodule] - - else: - - @property - def faststream_context(self) -> faststream.ContextRepo: - return self.context + @property + def faststream_context(self) -> faststream.ContextRepo: + return self.context def fetch_di_container(app_: faststream.FastStream | AsgiFastStream) -> Container: diff --git a/pyproject.toml b/pyproject.toml index 2e099e4..87ca9ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ classifiers = [ "Typing :: Typed", "Topic :: Software Development :: Libraries", ] -dependencies = ["faststream>=0.5,<0.7", "modern-di>=2,<3"] +dependencies = ["faststream>=0.7,<0.8", "modern-di>=2,<3"] version = "0" [project.urls]