Skip to content

2.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 13 Jul 19:30
33ed671

modern-di-grpc 2.1.0 — adopt the modern-di integration kit

Maintenance release. No public API changeDIInterceptor,
DIAioInterceptor, FromDI, inject, fetch_di_container, and
grpc_context_provider keep their signatures and behavior. Swaps this
package's hand-rolled connection-context seeding and marker resolution for
the shared primitives in
modern_di.integrations,
shipped in
modern-di 2.28.0.
Eighth 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,
modern-di-flask 2.1.0,
modern-di-faststream 2.10.0,
and
modern-di-typer 2.3.0).
This conversion was explicitly anticipated by modern-di's own decision
record addendum: "grpc's _build_child collapses to one bind() call,
dropping its post-hoc set_context entirely." gRPC has exactly one
connection provider, so bind() is used directly with no
classify_connection.

Internal refactors

  • _build_child collapsed from a two-step "build then post-hoc
    set_context" into one integrations.bind(grpc_context_provider, context) call
    , passing the derived context directly to
    build_child_container(scope=match.scope, context=match.context).
  • _FromDI is gone; FromDI = integrations.from_di. _parse_inject_params
    is deleted entirely (its body duplicated integrations.parse_markers
    exactly); inject now calls integrations.parse_markers directly.
    _resolve delegates to integrations.resolve_markers.
  • Both T/T_co TypeVars and the dataclasses import are removed (dead
    once the old marker class is gone) — this repo's inject was never
    generic over T, so unlike the modern-di-typer/modern-di-flask
    conversions, neither TypeVar survives.
  • architecture/dependency-injection.md's "Per-RPC scope" and "FromDI
    marker + inject decorator" sections promoted to describe the new
    internals.

Packaging

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

Downstream

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

Internals

  • 100% line coverage; ruff, ty clean across Python 3.10–3.14. Both the
    sync (DIInterceptor) and async (DIAioInterceptor) paths are fully
    exercised.
  • Built via subagent-driven-development: 5 planned tasks, each with an
    independent spec+quality review; a whole-branch review before merge that
    verified at the source level (Container/ContextRegistry internals)
    that passing context at construction time is provably equivalent to the
    old post-hoc set_context call.