|
| 1 | +# modern-di-aiohttp 2.2.0 — adopt the modern-di integration kit |
| 2 | + |
| 3 | +Maintenance release. **No public API change** — `FromDI`, `inject`, |
| 4 | +`setup_di`, `fetch_di_container`, `fetch_request_container`, and the |
| 5 | +connection providers keep their signatures and behavior. Swaps this |
| 6 | +package's hand-rolled connection dispatch and marker resolution for the |
| 7 | +shared primitives in |
| 8 | +[`modern_di.integrations`](https://github.com/modern-python/modern-di/blob/main/architecture/integration-kit.md), |
| 9 | +shipped in |
| 10 | +[modern-di 2.28.0](https://github.com/modern-python/modern-di/releases/tag/2.28.0). |
| 11 | +Fourth of 13 planned adapter conversions across the `modern-di` ecosystem |
| 12 | +(after |
| 13 | +[`modern-di-starlette` 2.2.0](https://github.com/modern-python/modern-di-starlette/releases/tag/2.2.0), |
| 14 | +[`modern-di-fastapi` 2.10.0](https://github.com/modern-python/modern-di-fastapi/releases/tag/2.10.0), |
| 15 | +and |
| 16 | +[`modern-di-litestar` 2.13.0](https://github.com/modern-python/modern-di-litestar/releases/tag/2.13.0)). |
| 17 | + |
| 18 | +## Internal refactors |
| 19 | + |
| 20 | +- **`_di_middleware` keeps its own `can_prepare()` handshake probe** to |
| 21 | + select `aiohttp_websocket_provider` or `aiohttp_request_provider` — this |
| 22 | + package is a documented outlier: both providers bind `web.Request` (a |
| 23 | + WebSocket is an upgraded HTTP request at aiohttp's middleware entry |
| 24 | + point), so `integrations.classify_connection`'s isinstance-over-tuple |
| 25 | + dispatch cannot distinguish them. Once the provider is picked, |
| 26 | + **`integrations.bind(provider, request)`** now derives the scope/context |
| 27 | + the middleware used to hand-write. `bind()` never returns `None`, so no |
| 28 | + fallback branch is needed. |
| 29 | +- **The child container's manual `try`/`finally: await |
| 30 | + child_container.close_async()` is now `Container`'s own `async with`** — |
| 31 | + entering an already-open container is a no-op; exiting closes it, |
| 32 | + including on the exception path. |
| 33 | +- **`_FromDI`/`_parse_inject_params`/`_resolve_di_params` are gone.** |
| 34 | + `FromDI = integrations.from_di`; `inject` now composes |
| 35 | + `integrations.parse_markers`/`integrations.resolve_markers`. |
| 36 | + |
| 37 | +## Packaging |
| 38 | + |
| 39 | +- Bumps the `modern-di` floor to `>=2.28.0,<3`. |
| 40 | + |
| 41 | +## Downstream |
| 42 | + |
| 43 | +No action needed — the public API (`FromDI`, `inject`, `setup_di`, |
| 44 | +`fetch_di_container`, `fetch_request_container`, |
| 45 | +`aiohttp_request_provider`/`aiohttp_websocket_provider`) is unchanged. |
| 46 | +Upgrading only requires `modern-di>=2.28.0`. |
| 47 | + |
| 48 | +## Internals |
| 49 | + |
| 50 | +- 100% line coverage; `ruff`, `ty` clean across Python 3.10–3.14. |
| 51 | +- Built via `subagent-driven-development`: 5 planned tasks, each with an |
| 52 | + independent spec+quality review; a whole-branch review before merge. |
0 commit comments