Skip to content

Adopt the modern-di integration kit#3

Merged
lesnik512 merged 6 commits into
mainfrom
integration-kit-conversion
Jul 13, 2026
Merged

Adopt the modern-di integration kit#3
lesnik512 merged 6 commits into
mainfrom
integration-kit-conversion

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

modern-di 2.28.0 shipped modern_di.integrations — framework-agnostic primitives that formalize what this package's build_di_container and Dependency/FromDI already hand-roll. This swaps the hand-rolled internals for kit calls. No public-API change; zero test-file changes.

Eleventh of 13 planned adapter conversions (after starlette 2.2.0, fastapi 2.10.0, litestar 2.13.0, aiohttp 2.2.0, flask 2.1.0, faststream 2.10.0, typer 2.3.0, grpc 2.1.0, celery 2.1.0, arq 2.1.0).

taskiq is a native-DI adapter (uses taskiq's own TaskiqDepends), with a single connection provider (taskiq_message_provider, binding taskiq.TaskiqMessage) — so, like grpc, it uses integrations.bind() directly with no classify_connection and no if match else None fallback (unlike fastapi/litestar, which have two providers). And like fastapi/litestar/faststream, Dependency's field holds an integrations.Marker while FromDI keeps wrapping taskiq's own TaskiqDepends.

  • build_di_container derives scope/context via integrations.bind(taskiq_message_provider, context.message) and opens the child via async with ... as container: yield container, replacing the manual try/finally: close_async().
  • Dependency's field renamed to marker: integrations.Marker[T_co]; __call__ delegates to self.marker.resolve(request_container). FromDI constructs Dependency(integrations.Marker(dependency)).
  • No dead imports (native-DI adapter); setup_di, fetch_di_container, and the worker-event lifecycle wiring are untouched.
  • architecture/dependency-injection.md promoted to describe the new internals.
  • Bumps the modern-di floor to >=2.28,<3.

Test plan

  • just test-ci — 100% line coverage, all 7 tests passing (uses InMemoryBroker, no external service), zero test-file changes
  • just lint-ci — ruff, ty, check-planning all clean
  • Per-task spec + quality review (5 tasks, all approved)
  • Whole-branch review (approved, no findings — including a traced verification that the async-generator-inside-async with structure preserves the original try/finally's close-timing on both the normal and task-error paths)

@lesnik512
lesnik512 merged commit 6ad2569 into main Jul 13, 2026
6 checks passed
@lesnik512
lesnik512 deleted the integration-kit-conversion branch July 13, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant