Skip to content

Conversation

@BrianPugh
Copy link
Contributor

There are some situations where multiple libraries/frameworks are inspecting Annotated types. For example, the following example code using the Cyclopts CLI library:

from dependency_injector.wiring import Provide, inject
from cyclopts import Parameter

@app.default
@inject
def main(
    name: str,
    *,
    greeting_service: Annotated[GreetingService, Provide[Container.greeting_service], Parameter(parse=False)],
):
    ...

Currently, dependency_injector is only looking at the first annotation. This PR updates the logic to use the first valid extracted marker. This way, the dependency_injector marker no longer has to be the first annotated element.

Issue that brought this up: BrianPugh/cyclopts#704

@BrianPugh
Copy link
Contributor Author

#940 needs to be merged in first to fix tests.

@ZipFile ZipFile changed the base branch from master to develop December 4, 2025 18:05
@ZipFile ZipFile force-pushed the annotated-non-first branch from 147c234 to 62fb745 Compare December 4, 2025 18:06
@coveralls
Copy link

Coverage Status

coverage: 94.982% (+0.03%) from 94.956%
when pulling 62fb745 on BrianPugh:annotated-non-first
into 244deee on ets-labs:develop.

@ZipFile ZipFile merged commit 51f8187 into ets-labs:develop Dec 4, 2025
13 checks passed
@ZipFile
Copy link
Contributor

ZipFile commented Dec 4, 2025

Thanks! Fix from #940 is not really needed, since we already had one in #933.

@ZipFile
Copy link
Contributor

ZipFile commented Dec 4, 2025

Available in v4.48.3

@jochumdev
Copy link

jochumdev commented Dec 4, 2025

For anyone looking into integrating those 2:

BrianPugh/cyclopts#704 (comment)

@BrianPugh this was bugging me too, thx for fixing it!

Edit: I also love to use python-dependency-injector, it's a very very powerful tool.

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.

4 participants