Skip to content

tiangolo/depende

Repository files navigation

Depende

Dependency declarations for Python frameworks and tools.

Test Python package version


Documentation: https://depende.tiangolo.com

Source Code: https://github.com/tiangolo/depende


depende provides small dependency declarations in the style of FastAPI for reuse by frameworks and tools.

Install

uv add depende

Or if using pip:

pip install depende

Usage

from depende import Depends, DependsInfo

Depends(...) returns a frozen DependsInfo metadata object with:

  • dependency: a callable dependency, or None
  • use_cache: whether a framework may reuse the dependency result within its active solving context
  • scope: an opaque framework-defined string, or None

The package only declares dependency metadata. It does not solve, execute, cache, inject request data, manage lifecycles, generate OpenAPI, or define framework-specific scopes.

Example

from depende import Depends
from typing import Annotated


def get_settings() -> dict[str, str]:
    return {"mode": "prod"}


SettingsDep = Annotated[dict[str, str], Depends(get_settings, scope="command")]

Frameworks decide what scope means and how dependency solving works.

License

This project is licensed under the terms of the MIT license.

About

Dependency declarations for Python frameworks and tools

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors