Skip to content

v2.3.2

Choose a tag to compare

@dperezcabrera dperezcabrera released this 10 Jul 15:26
· 32 commits to main since this release

Patch release: lazy components with async @configure are now resolvable.

What's fixed

inspect.isawaitable() on a lazy component's proxy touched __class__, which forced synchronous materialization — so await container.aget(LazyAsyncComponent) raised AsyncResolutionError even though the error message recommended exactly that call. Both get() and aget() now guard the check, with two effects:

  • aget() of a lazy component with async @configure works.
  • Lazy components materialize on FIRST USE, not at resolution time — true lazy semantics.

Example

@component(lazy=True)
class Warmup:
    @configure
    async def load(self):
        self.ready = True

container = init(modules=["app"])
warmup = await container.aget(Warmup)   # previously raised; now configures and returns

Compatibility

  • No API changes. Python >= 3.11.
  • Behavioral note: code that relied on the accidental eager materialization of lazy components during get() will now see materialization deferred to first attribute access.

Tests

550 checks passing. New regression suite for error contracts (async-configured lazies via sync access, ContainerObserver callbacks, refresh_config() without tree sources). Additionally validated by the flagship e2e (15 modules, real Postgres/Redis/RabbitMQ/Kafka).

Install

pip install -U pico-ioc