Skip to content

2.10.0

Latest

Choose a tag to compare

@github-actions github-actions released this 13 Jul 16:57
0022bbc

modern-di-faststream 2.10.0 — adopt the modern-di integration kit

Maintenance release. No public API changeFromDI, setup_di,
fetch_di_container, and faststream_message_provider keep their
signatures and behavior. Swaps this package's hand-rolled connection
dispatch and marker resolution for the shared primitives in
modern_di.integrations,
shipped in
modern-di 2.28.0.
Sixth of 13 planned adapter conversions across the modern-di ecosystem
(after
modern-di-starlette 2.2.0,
modern-di-fastapi 2.10.0,
modern-di-litestar 2.13.0,
modern-di-aiohttp 2.2.0,
and
modern-di-flask 2.1.0).
FastStream combines traits from two prior conversions: like Flask, it has
exactly one connection/message type, so integrations.bind() is used
directly with no classify_connection; unlike Flask, its DI middleware
wraps a single call site, so a Container async-context-manager block is
introduced.

Internal refactors

  • _DiMiddleware.consume_scope now derives scope/context via
    integrations.bind(faststream_message_provider, msg)
    , and opens the
    per-message child container via async with ... as request_container:
    replacing the manual try/finally: await request_container.close_async().
    The existing with self.context.scope(_REQUEST_CONTAINER_KEY, request_container): block stays a separate, nested plain with
    (ContextRepo.scope is not an async context manager, so it can't combine
    into one async with A, B: statement).
  • Dependency's field is renamed from a raw dependency to
    marker: integrations.Marker[T_co]; __call__ becomes
    self.marker.resolve(request_container).
    FromDI now constructs
    Dependency(integrations.Marker(dependency)) — its own signature
    (dependency, *, use_cache, cast) is unchanged.
  • Like modern-di-fastapi/modern-di-litestar, this package is a
    native-DI adapter (FastStream's own Depends drives resolution): no
    hand-rolled @inject decorator, no parse_markers/resolve_markers
    usage.
  • The root container's callback-based lifecycle
    (app.on_startup(container.open) / app.after_shutdown(container.close_async))
    and the _DIMiddlewareFactory/_DiMiddleware two-class split are
    untouched by this change.

Packaging

  • Bumps the modern-di floor to >=2.28,<3.

Downstream

No action needed — the public API (FromDI, setup_di,
fetch_di_container, faststream_message_provider) is unchanged.
Upgrading only requires modern-di>=2.28.0.

Internals

  • 100% line coverage; ruff, ty clean across Python 3.10–3.14.
  • Built via subagent-driven-development: 5 planned tasks, each with an
    independent spec+quality review; a whole-branch review before merge that
    traced the new nested async-with/with structure's exception ordering
    against the original try/finally.