Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions architecture/injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ The wrapper runs on every invocation:
2. Build the per-command `Scope.REQUEST` container and stash it on `ctx.meta`
(see [scopes.md](scopes.md)).
3. If there are `FromDI` parameters, `_resolve_di_params` resolves each from the
command container — `resolve_provider(...)` for provider markers,
`resolve(dependency_type=...)` for bare types — and fills them into the call.
command container via `resolve_dependency(...)` — modern-di's single
provider-or-type dispatch — and fills them into the call.
4. Call the original function; close the command container on return.

`FromDI` parameters coexist with ordinary Typer arguments and options: because
Expand Down
9 changes: 1 addition & 8 deletions modern_di_typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,7 @@ def _resolve_di_params(
cmd_container: Container,
di_params: dict[str, _FromDI[typing.Any]],
) -> dict[str, typing.Any]:
return {
name: (
cmd_container.resolve_provider(marker.provider)
if isinstance(marker.provider, providers.AbstractProvider)
else cmd_container.resolve(dependency_type=marker.provider)
)
for name, marker in di_params.items()
}
return {name: cmd_container.resolve_dependency(marker.provider) for name, marker in di_params.items()}


def inject(func: typing.Callable[..., T]) -> typing.Callable[..., T]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"Typing :: Typed",
"Topic :: Software Development :: Libraries",
]
dependencies = ["typer>=0.9,<1", "modern-di>=2.19.0,<3"]
dependencies = ["typer>=0.9,<1", "modern-di>=2.25.0,<3"]
version = "0"

[project.urls]
Expand Down
Loading