Repository navigation
4.2.1
4.2.1 fixes three bugs: a finalizer that never ran, an optional dependency that was injected as None, and a generic class creator that wired nothing. There are no API changes.
Fixed
- A cached instance whose creator finishes on another thread while the container is closing is now finalized by the next close, as the lifecycle docs say. Before, the close dropped it from the finalizer queue: it stayed cached, no later close or reopen finalized it, and whatever it held leaked. A close with cached items now copies its queue, which costs about 40 ns per close. (#719, #726)
- A creator parameter annotated
Annotated[X, ...] | None(or a union of annotated types) and read from the creator's__signature__, as for Pydantic models and msgspecStructs, is now resolved fromX's provider. Before, it was injected asNoneeven withXregistered, and a union of two annotated members failedvalidate(). A common case is the Pydantic fieldAnnotated[X, Field(...)] | None = None. (#720, #724) Factory(Repo[int]), with a parameterized generic class as the creator, now wiresRepo's constructor parameters by type, is checked byvalidate(), and is bound toRepo. CallingRepo[int]still builds the instance. Before, it wired nothing, had no bound type, passedvalidate(), and failed on first resolve with a rawTypeError. Two parameterizations of one class now share the bound typeRepo, so registering both needsbound_type=on them. (#722, #725)
What's Changed
- docs: add shutdown-order tests to the integration checklist by @lesnik512 in #707
- docs: regenerate the performance tables after the per-factory code change by @lesnik512 in #708
- docs: state that the performance tables were measured on 4.2.0 by @lesnik512 in #709
- docs: explain that Litestar closes the request container before a stream body runs by @lesnik512 in #710
- docs: note that modern-di-faststream 4.2.2 drops the request container context key by @lesnik512 in #711
- docs: say Celery tasks resolve from their own app's container by @lesnik512 in #712
- docs: plainer prose in the benchmarks README and AGENTS.md by @lesnik512 in #713
- docs: replace emoji link headings with a Links section (RM3) by @lesnik512 in #714
- docs: say a cancelled sync stream on the grpc aio server is never closed by @lesnik512 in #715
- docs: match AGENTS.md to the standard's canonical justfile sentence by @lesnik512 in #716
- docs: say aiogram error handlers get their own child container by @lesnik512 in #718
- docs: use colons in place of em dashes in gloss bullets by @lesnik512 in #717
- fix: wire an Annotated union member read from a creator's signature by @lesnik512 in #724
- fix: wire a parameterized generic class creator from its origin by @lesnik512 in #725
- fix: finalize a cached instance built during a close at the next close by @lesnik512 in #726
Full Changelog: 4.2.0...4.2.1