Skip to content

Fix injection from postponed Annotated annotations - #992

Open
antesmd wants to merge 1 commit into
ets-labs:developfrom
antesmd:fix/postponed-annotated-injections
Open

antesmd wants to merge 1 commit into
ets-labs:developfrom
antesmd:fix/postponed-annotated-injections

Conversation

@antesmd

@antesmd antesmd commented Nov 30, 2026

Copy link
Copy Markdown

Problem

When from __future__ import annotations is enabled, parameter annotations
are stored as strings. Wiring does not resolve them before looking for
injection markers, so dependencies declared with Annotated are missed.

For example, a FastAPI endpoint using
Annotated[Service, Depends(Provide[Container.service])] can receive the
Provide marker instead of the service.

Changes

  • Resolve string parameter annotations before searching for markers, including
    aliases of Annotated.
  • Keep processing other parameters when an annotation cannot be resolved.
  • Check the parameter default when Annotated contains no injection marker.
  • Add FastAPI regression tests and correct the existing annotated endpoint test.

Testing

  • pytest tests/unit/wiring -q — 171 passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant