fast-depends
FastDepends - extracted and cleared from HTTP domain logic FastAPI Dependency Injection System. Async and sync are both supported.
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 on this page — 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
fast-depends on PyPI
pip
pip install fast-dependsuv
uv add fast-dependspoetry
poetry add fast-dependsInstalling 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 the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — anyio, typing-extensions |
| Maintenance | actively maintained — 165 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,039,686/month — #3,348 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fast_depends-3.0.8-py3-none-any.whl
Keywords: fastapi, dependency injection
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
fastapi-decoratorsConverts functions into FastAPI-compatible…
permissive · top 15,000 on PyPI
fastapi-injectableEnables FastAPI's Depends() dependency…
permissive · top 15,000 on PyPI
taskiq-dependenciesProvides FastAPI-style dependency injection for…
unclear · top 5,000 on PyPI
simple-diA strictly typed dependency injection library…
permissive · top 15,000 on PyPI
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
in-n-outLightweight dependency injection framework…
permissive · top 15,000 on PyPI
fastapi-injectorIntegrates the injector dependency-injection…
permissive · top 15,000 on PyPI
fastapi-sessionsAdds session authentication to FastAPI…
permissive · top 15,000 on PyPI
cadwynCadwyn generates older API versions…
permissive · top 5,000 on PyPI
taskiq-fastapiIntegrates FastAPI request and dependency…
permissive · top 15,000 on PyPI