skillfed

fast-depends

FastDepends - extracted and cleared from HTTP domain logic FastAPI Dependency Injection System. Async and sync are both supported.

fast-depends v3.0.8 2.0M downloads/30d#3,348 on PyPI517
Permissive license MIT Active released

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-depends

uv

uv add fast-depends

poetry

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 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

Development Status :: 5 - Production/StableFramework :: PydanticFramework :: Pydantic :: 1Framework :: Pydantic :: 2Intended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

dependency injection frameworkfastapi di without httpasync sync dependency resolvertype validation injectionpydantic-based di container
dependency-injectiontype-validationasync-sync

More Software Development packages