--- id: typer-injector version: "0.3.0" license: MIT license_treatment: permissive maintenance: active --- # typer-injector — Dependency injection for typer License: permissive · Maintenance: active · Downloads: 102.9K/mo ## What it is and what it does typer-injector bridges Typer CLI applications with FastAPI-style dependency injection, letting you define reusable parameter factories and inject them into commands via type annotations. Instead of repeating the same option parsing logic across multiple commands, you write a dependency function once and reference it by annotating parameters with Depends(). The package wraps Typer's InjectingTyper class and works with Typer's Option and Argument annotations. It's useful when your CLI has multiple commands that share common parameters—like database connections, configuration objects, or parsed composite arguments—that you want to define and validate in one place. The dependency system resolves these at command invocation time, similar to how FastAPI resolves dependencies for route handlers. Use it for: - Share parsed configuration (host, port, credentials) across multiple CLI commands without repeating option definitions. - Build composite parameters from multiple CLI options—e.g., combine host and port into an Address tuple for reuse. - Centralize validation logic for common parameter types across a multi-command CLI tool. - Reduce boilerplate in CLI tools with many commands that accept overlapping sets of options. - Organize CLI parameter handling using dependency injection patterns familiar from web frameworks. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds FastAPI-style dependency injection to Typer CLI applications, allowing you to define reusable parameter dependencies and inject them into multiple commands. Yes, if you're building a Typer CLI with multiple commands that share parameters or need centralized dependency logic. The package is actively maintained, has low install friction, carries no security vulnerabilities, and uses a permissive MIT license. Start with it if you're already using Typer and find yourself repeating option definitions across commands. ## Install pip install typer-injector uv add typer-injector poetry add typer-injector ## Installing typer-injector Before you install: Low friction installation with a single runtime dependency on typer. Actively maintained with recent commits and broad Python version support from 3.9 through 3.14. License in practice: MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects. Quickstart: pip install typer-injector import typer from typer_injector import Depends, InjectingTyper from typing import Annotated app = InjectingTyper() def my_dependency(value: str) -> str: return value.upper() Dep = Annotated[str, Depends(my_dependency)] @app.command() def my_command(dep: Dep) -> None: print(dep) Verify before relying: - Whether dependency caching or lifecycle management (request-scoped, singleton, etc.) is supported beyond the FastAPI pattern. - Performance characteristics when many commands share complex dependency graphs. - Compatibility with Typer's async command support. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 102.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags typer dependency injection, cli dependency management, typer command parameters, fastapi-style cli injection, reusable cli dependencies, typer parameter sharing, cli argument composition, cli-framework, dependency-injection, typer [View on SkillFed](https://skillfed.io/packages/typer-injector) · [View on PyPI](https://pypi.org/project/typer-injector/)