|
| 1 | +# modern-di-fastapi 2.10.0 — adopt the modern-di integration kit |
| 2 | + |
| 3 | +Maintenance release. **No public API change** — `setup_di`, `FromDI`, |
| 4 | +`build_di_container`, `fetch_di_container`, and the context providers keep |
| 5 | +their signatures and behavior. Swaps this package's hand-rolled connection |
| 6 | +dispatch and marker resolution for the shared primitives in |
| 7 | +[`modern_di.integrations`](https://github.com/modern-python/modern-di/blob/main/architecture/integration-kit.md), |
| 8 | +shipped in |
| 9 | +[modern-di 2.28.0](https://github.com/modern-python/modern-di/releases/tag/2.28.0). |
| 10 | +This is the second of 13 planned adapter conversions across the `modern-di` |
| 11 | +ecosystem (after |
| 12 | +[`modern-di-starlette` 2.2.0](https://github.com/modern-python/modern-di-starlette/releases/tag/2.2.0)). |
| 13 | + |
| 14 | +## Internal refactors |
| 15 | + |
| 16 | +- **`build_di_container`'s isinstance-over-tuple connection dispatch is now |
| 17 | + `integrations.classify_connection`.** |
| 18 | +- **The child container's manual `try`/`finally: await container.close_async()` |
| 19 | + is now `Container`'s own `async with`** — entering an already-open container |
| 20 | + is a no-op; exiting closes it, including on the exception path. |
| 21 | +- **`Dependency`'s field changes from a raw `dependency` to |
| 22 | + `marker: integrations.Marker[T_co]`; `__call__` becomes |
| 23 | + `self.marker.resolve(request_container)`.** `FromDI` now constructs |
| 24 | + `Dependency(integrations.Marker(dependency))` — its own public signature |
| 25 | + (`dependency`, `use_cache`) is unchanged. |
| 26 | +- Unlike `modern-di-starlette`'s conversion, this package is a **native-DI** |
| 27 | + adapter (FastAPI's own `Depends` drives resolution): no `@inject` decorator |
| 28 | + to replace, no `parse_markers`/`resolve_markers` usage, and no imports |
| 29 | + become dead. |
| 30 | + |
| 31 | +## Packaging |
| 32 | + |
| 33 | +- Bumps the `modern-di` floor to `>=2.28.0,<3`. |
| 34 | + |
| 35 | +## Downstream |
| 36 | + |
| 37 | +No action needed — the public API (`setup_di`, `FromDI`, `build_di_container`, |
| 38 | +`fetch_di_container`, `fastapi_request_provider`/`fastapi_websocket_provider`) |
| 39 | +is unchanged, and no test in this package's own suite needed to change. |
| 40 | +Upgrading only requires `modern-di>=2.28.0`. |
| 41 | + |
| 42 | +## Internals |
| 43 | + |
| 44 | +- 100% line coverage; `ruff`, `ty` clean across Python 3.10–3.14. |
| 45 | +- `architecture/container-lifecycle.md` and `architecture/dependency-resolution.md` |
| 46 | + updated to describe the new internals. |
| 47 | +- Built via `subagent-driven-development`: 5 planned tasks, each with an |
| 48 | + independent spec+quality review; a whole-branch review before merge. |
0 commit comments