From 6f2dca83939fc2ee32a424baa6afc3ba24d3d87e Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Wed, 8 Apr 2026 21:34:24 +0300 Subject: [PATCH] fix faststream imports --- lite_bootstrap/bootstrappers/faststream_bootstrapper.py | 6 +++++- tests/test_faststream_bootstrap.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lite_bootstrap/bootstrappers/faststream_bootstrapper.py b/lite_bootstrap/bootstrappers/faststream_bootstrapper.py index 5756b56..68ced88 100644 --- a/lite_bootstrap/bootstrappers/faststream_bootstrapper.py +++ b/lite_bootstrap/bootstrappers/faststream_bootstrapper.py @@ -51,11 +51,15 @@ def __init__( ) -> None: ... +def _make_asgi_faststream() -> "AsgiFastStream": + return AsgiFastStream() + + @dataclasses.dataclass(kw_only=True, slots=True, frozen=True) class FastStreamConfig( HealthChecksConfig, LoggingConfig, OpentelemetryConfig, PrometheusConfig, PyroscopeConfig, SentryConfig ): - application: "AsgiFastStream" = dataclasses.field(default_factory=AsgiFastStream) + application: "AsgiFastStream" = dataclasses.field(default_factory=_make_asgi_faststream) opentelemetry_middleware_cls: type[FastStreamTelemetryMiddlewareProtocol] | None = None prometheus_middleware_cls: type[FastStreamPrometheusMiddlewareProtocol] | None = None diff --git a/tests/test_faststream_bootstrap.py b/tests/test_faststream_bootstrap.py index f6a2b66..300d984 100644 --- a/tests/test_faststream_bootstrap.py +++ b/tests/test_faststream_bootstrap.py @@ -85,6 +85,11 @@ async def test_faststream_bootstrap_health_check_wo_broker() -> None: bootstrapper.teardown() +def test_faststream_config_default_application() -> None: + config = FastStreamConfig() + assert isinstance(config.application, faststream.asgi.AsgiFastStream) + + def test_faststream_bootstrapper_not_ready() -> None: with emulate_package_missing("faststream"), pytest.raises(RuntimeError, match="faststream is not installed"): FastStreamBootstrapper(bootstrap_config=FastStreamConfig(application=faststream.asgi.AsgiFastStream()))