--- id: fast-depends version: "3.0.8" license: MIT license_treatment: permissive maintenance: active --- # fast-depends — FastDepends - extracted and cleared from HTTP domain logic FastAPI Dependency Injection System. Async and sync are both supported. License: permissive · Maintenance: active · Downloads: 2.0M/mo ## What it is and what it does FastDepends is a lightweight dependency injection container extracted from FastAPI's internals, stripped of HTTP-specific logic to work as a standalone library. It lets you decorate functions with @inject to automatically resolve dependencies, cast arguments to their annotated types, and validate inputs using pydantic—all without requiring a web framework. Both synchronous and asynchronous functions are supported equally, and return values are also cast according to type annotations. The library is designed to bring FastAPI's familiar DI patterns into non-web applications, legacy frameworks like Flask, or as a foundation for building custom frameworks. It includes a dependency override system for testing and a custom field mechanism for extending behavior, making it useful for message queues, CLI tools, and other contexts where you want structured dependency resolution without HTTP overhead. Use it for: - Add FastAPI-style dependency injection to Flask or other non-async frameworks for cleaner parameter handling. - Build CLI tools or background job runners that need type validation and dependency resolution without a web server. - Create a custom framework or message queue handler (like Propan or FastStream) with built-in DI support. - Write testable async code with easy dependency mocking via the dependency override system. - Validate and cast function arguments automatically using pydantic without writing custom decorators. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. FastDepends provides a standalone dependency injection system extracted from FastAPI, supporting both sync and async code with automatic type casting and pydantic validation. Yes. FastDepends is actively maintained, has no known vulnerabilities, minimal dependencies, and solves a real problem—bringing FastAPI's clean DI patterns to non-web code. It's worth installing if you want structured dependency injection with type validation in sync or async code outside a web framework, or as a building block for custom frameworks. ## Install pip install fast-depends uv add fast-depends poetry add fast-depends ## Installing fast-depends Before you install: Low friction installation with just two runtime dependencies (anyio and typing-extensions). The package is actively maintained with a recent release and no known vulnerabilities. License in practice: MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal attribution requirements. Quickstart: pip install fast-depends from fast_depends import inject, Depends def dependency(a: int) -> int: return a @inject def main(a: int, b: int, c: int = Depends(dependency)) -> float: return a + b + c assert main("1", 2) == 4.0 Requires Python 3.10 or later. Verify before relying: - Whether custom field extensibility is sufficient for complex framework-building use cases beyond the documented Header example. - Performance characteristics compared to native FastAPI dependency injection or other standalone DI libraries. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 2.0M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags dependency injection framework, fastapi di without http, async sync dependency resolver, type validation injection, pydantic-based di container, dependency-injection, type-validation, async-sync [View on SkillFed](https://skillfed.io/packages/fast-depends) · [View on PyPI](https://pypi.org/project/fast-depends/)