Skip to content

4.2.1

Choose a tag to compare

@github-actions github-actions released this 18 Oct 10:04
· 8 commits to main since this release
4.2.1
39b91a1

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 msgspec Structs, is now resolved from X's provider. Before, it was injected as None even with X registered, and a union of two annotated members failed validate(). A common case is the Pydantic field Annotated[X, Field(...)] | None = None. (#720, #724)
  • Factory(Repo[int]), with a parameterized generic class as the creator, now wires Repo's constructor parameters by type, is checked by validate(), and is bound to Repo. Calling Repo[int] still builds the instance. Before, it wired nothing, had no bound type, passed validate(), and failed on first resolve with a raw TypeError. Two parameterizations of one class now share the bound type Repo, so registering both needs bound_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