Skip to content

Commit 43c52ef

Browse files
authored
Merge pull request #73 from modern-python/fix-import
fix faststream imports
2 parents 0c0bc19 + 6f2dca8 commit 43c52ef

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lite_bootstrap/bootstrappers/faststream_bootstrapper.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ def __init__(
5151
) -> None: ...
5252

5353

54+
def _make_asgi_faststream() -> "AsgiFastStream":
55+
return AsgiFastStream()
56+
57+
5458
@dataclasses.dataclass(kw_only=True, slots=True, frozen=True)
5559
class FastStreamConfig(
5660
HealthChecksConfig, LoggingConfig, OpentelemetryConfig, PrometheusConfig, PyroscopeConfig, SentryConfig
5761
):
58-
application: "AsgiFastStream" = dataclasses.field(default_factory=AsgiFastStream)
62+
application: "AsgiFastStream" = dataclasses.field(default_factory=_make_asgi_faststream)
5963
opentelemetry_middleware_cls: type[FastStreamTelemetryMiddlewareProtocol] | None = None
6064
prometheus_middleware_cls: type[FastStreamPrometheusMiddlewareProtocol] | None = None
6165

tests/test_faststream_bootstrap.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ async def test_faststream_bootstrap_health_check_wo_broker() -> None:
8585
bootstrapper.teardown()
8686

8787

88+
def test_faststream_config_default_application() -> None:
89+
config = FastStreamConfig()
90+
assert isinstance(config.application, faststream.asgi.AsgiFastStream)
91+
92+
8893
def test_faststream_bootstrapper_not_ready() -> None:
8994
with emulate_package_missing("faststream"), pytest.raises(RuntimeError, match="faststream is not installed"):
9095
FastStreamBootstrapper(bootstrap_config=FastStreamConfig(application=faststream.asgi.AsgiFastStream()))

0 commit comments

Comments
 (0)